Invoque .lib from c# project?

  • Thread starter Thread starter Marty
  • Start date Start date
Would it not be better to first turn the .lib into something executable like
a dll or similar?

If you insists everything is possible but the costs are way too high.
 
I just did a test to compile the .lib into a DLL.

I tried to reference this DLL in my C# project. It didn't work, it was
not a valid COM component. I should wrap the DLL/Lib code first to make
it COM.

I don't know where to start with that. Do you have any idea or tutorial
to suggest to me, I appreciate a lot!

Thank you
Marty
 
Don't you have the source? Guess not.

So, somebody else has provided a .lib that you could link your own thing
with, right?

Now, you want to use this from C# so you know what is in the .lib?

I don't know about wrapper creation but it can be done for sure.

Have a good search for something like "using a dll from C#", you get what I
mean.

If you have msdn it might be in there as well and there is always google.
 
Marty,

What you will want to do is export your functions in a DLL, or create a
COM object wrapper. Then, you can access the functionality through the
P/Invoke layer, or through COM interop.

Hope this helps.
 
No you don't, you can call the exported functions using PInvoke interop.

Willy.
 
Assuming you know the method signatures in the library, after compiling
it to dll, then use PInvoke to call it from C#. Exposing it as COM will
be too complex and will slow the performance down considerably.

If this lib/dll is a vital component and will be used by multiple
applications, I would create a wrapper for it in Managed C++ so it will
be exposed as .NET component. Not only will that be easier to use
because you don't need to declare all the PInvoke from C#, but
performance will be slightly better because you can use the IJW feature
in MC++ in the wrapper.

Suriyanto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top