|
It's probably because your app is being compiled for "AnyCPU" instead of x86. There are no 64-bit drivers for this, and since you cannot mix 64 adn 32 bit code in the same process, you have to force your app to compile for x86 instead of AnyCPU.
|
|
|
|
|
Thanks for the fast reply. It is x86. Moreover, dbCommand.ExecuteReader() does read the data.
|
|
|
|
|
First, you do not have to open the connection first when using a DataAdapter. The DA will open and close the connection itself.
Second, instead of filling a DataTable, change this to use a DataSet instead. I've never done this with an Excel sheet, so there may be something funky going on that I don't know about.
|
|
|
|
|
I have an unusual situation.
A call from C# to C++ using static extern references to an un-mananged dll works perfectly during execution of TestClass/TestMethod unit testing within Visual Studio 2008. However, during debug (not during Testing) and normal execution, we receive an exception from the underlying COM object for which the C++ dll is a wrapper. And, right on queue, the third party COM object gives no detail why it failed.
I cannot much paste code because of proprietary reasons, however, here is the extern from C# which works fine under the context of unit testing (TestClass/TestMethod) in VS 2008.
[DllImport("BTDataAccess.dll")]
static extern uint BTReadBu( [In, MarshalAs(UnmanagedType.BStr)] string filePath);
Few notes, we do have the c++/unmanaged copied to both the C# test project and console app. Additionally, the list of c# project refernces between test and console projects have been reviewed.
Any ideas regardless of how far out they are would be appreciated.
|
|
|
|
|
Have you tried changing calling convention:
[DllImport("BTDataAccess.dll", CallingConvention=CallingConvention.SomeCallingConvention)]
I already had problems when debugging/running by different calling conventions, as some exceptions are not thrown immediatelly on release code (but are still wrong). Maybe that's the case... maybe.
Try the charset also. I am only guessing, as I really don't know what is causing the problem.
|
|
|
|
|
Thanks for the suggestion, however, none of the five CallingConvention enum values fixed the problem.
What do you mean by charset?
On another note, we are running this as a single-threaded operation. There is a call to the c++ unmanaged dll made prior to the one in question. However, it is tasks with simply instantiating a COM object. This first call and the second one which fails is performed on the same thread. Multi-threaded operations on COM brings a lot of issues, but this isn't the case here. I realize each unit test in VS is on its own thread, however, we rigged it that calls to the same COM object are not performed from different threads.
|
|
|
|
|
You use string. There is the CallingConvention and the CharSet properties.
Also, the calling convention can be wrong in the method that was called just before. So, if you instantiate a COM object and after call a method, is possible that the instantiation is using an invalid calling convention.
But, I am unsure... why you can't simple import your Com object by Visual Studio Add Referece? It creates the the available components with the right calling convention.
|
|
|
|
|
Ok, the plot thickens.
A fellow developer wrote a bare-bones c# app that calls the c++ wrapper dll and it works from his computer. However, it fails from mine.
I tried each type of CharSet without success. Also, I tried it with callingconvention = CallingConvention.StdCall.
Btw, we used to use the automatically interop dll for calling the COM directly, however, it was very unstable. The funny thing is that stability is perfect with the approach using a hand-written c++ wrapper if called from c# under the context of visual studio unit testing.
|
|
|
|
|
Hi friends, my problem is to calculate the CRC value in the comunication between two terminal.
the string so composed:
10 02 (Start)
36 01 03 0e 57 00 00 00 29 00 00 (Data)
10 03 (End)
01 65 (CRC)
I already tried some CRC calculator but I have not found a correct calculation.
Can anyone give me some suggestions?
Thank you
Bye
|
|
|
|
|
http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net
http://www.codeproject.com/KB/recipes/crc32_dotnet.aspx
|
|
|
|
|
Probably not a CRC32, as it's only 2 bytes, but who knows..
Maybe Fletcher-16?
|
|
|
|
|
hello all,
Application.Run(new Form1());
How can i start an application so that other instance don't start of the same application.
regard,
sohail
|
|
|
|
|
hi ,
have a look to this link it will help u
link
|
|
|
|
|
There are several articles here on CP that cover that in a number of ways.
|
|
|
|
|
mention please...!
|
|
|
|
|
|
At the top of the page you will see a box labelled Search. Type single instance into this box. Select Articles / Quick Answers in the dropdown next to it. Click the Go! button.
|
|
|
|
|
Thanks you all
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:58am.
|
|
|
|
|
Don't point out or raise comments on anyone like that. This question is not just learning for me it can save any other person's time. you are not a child my dear.
|
|
|
|
|
Sohial A Rana wrote: you are not a child my dear.
But it seems you are a child asking others to search for you.
|
|
|
|
|
i know every type of problem can be solved via search engine. if every problem solve by searching then why people raise questions here?
|
|
|
|
|
Sohial A Rana wrote: i know every type of problem can be solved via search engine. if every problem solve by searching then why people raise questions here
|
|
|
|
|
Sohial A Rana wrote: i know every type of problem can be solved via search engine. if every problem solve by searching then why people raise questions here?
People come here only if they do not find the information through search engines. Google gave me 1,76,000 results for "C# Single instance", the top two of which are CP articles. If you had even tried this, you wouldn't have posted this question here.
|
|
|
|
|
Do you have trouble clicking the Search button ?
|
|
|
|