I just wasted about 2-3 hours of my time because my assumption was wrong, and as it turns out that this problem is fairly common, but nobody cannot quite explain it.
I had to write a DLL so that you can call it from C#. There still are some things that is easier done in C++, especially when it comes to dealing with the drivers and I/O directly. Or you simply have someone else's DLL or Win32 DLL etc. you need to call from your C# (VB.NET).
The Problem,
You think you should add the DLL as a Reference in the same manner as other C# assemblies. So you do that then the system complains
A reference to "C\blah\blah\blah\younameit.DLL" could not be accessible. Please make sure that the file is accessible, a valid assemply or COM component.
The Bad Assumption
I thought that I add the reference to any DLLs that I access in my C# project.
The Correct Way
It is not necessary to reference the DLL. That reference is made in your Plaforom Invoke code. If this had not made sense, you should read up on System.Runtime.InteropServices
No comments:
Post a Comment