473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Invoque .lib from c# project?

Hi,

Can we invoque a .lib file that is made in c++ from a c# project?

Thanks
Marty
Nov 17 '05 #1
7 1188
at
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.

"Marty" <xm******@hotmail.com> wrote in message
news:_FWwe.100541$9A2.46104@edtnps89...
Hi,

Can we invoque a .lib file that is made in c++ from a c# project?

Thanks
Marty

Nov 17 '05 #2
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

at wrote:
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.

"Marty" <xm******@hotmail.com> wrote in message
news:_FWwe.100541$9A2.46104@edtnps89...
Hi,

Can we invoque a .lib file that is made in c++ from a c# project?

Thanks
Marty


Nov 17 '05 #3
at
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" <xm******@hotmail.com> wrote in message
news:s_Wwe.68705$wr.860@clgrps12...
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

at wrote:
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.

"Marty" <xm******@hotmail.com> wrote in message
news:_FWwe.100541$9A2.46104@edtnps89...
Hi,

Can we invoque a .lib file that is made in c++ from a c# project?

Thanks
Marty



Nov 17 '05 #4
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Marty" <xm******@hotmail.com> wrote in message
news:s_Wwe.68705$wr.860@clgrps12...
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

at wrote:
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.

"Marty" <xm******@hotmail.com> wrote in message
news:_FWwe.100541$9A2.46104@edtnps89...
Hi,

Can we invoque a .lib file that is made in c++ from a c# project?

Thanks
Marty



Nov 17 '05 #5
No you don't, you can call the exported functions using PInvoke interop.

Willy.
"Marty" <xm******@hotmail.com> wrote in message
news:s_Wwe.68705$wr.860@clgrps12...
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

at wrote:
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.

"Marty" <xm******@hotmail.com> wrote in message
news:_FWwe.100541$9A2.46104@edtnps89...
Hi,

Can we invoque a .lib file that is made in c++ from a c# project?

Thanks
Marty



Nov 17 '05 #6
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

Nov 17 '05 #7
Thank you everybody, I'll try the PInvoke.
Regards,
Marty

Suriyanto Lee wrote:
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

Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: public heath vb developer | last post by:
We have a solution with 29 projects including a main menu and 28 dlls. One of the projects (Project B) was created by copying an existing project (Project A), making changes including the assembly...
5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
0
by: Patty O'Dors | last post by:
Hi I am experiencing the following issue when building an ATL component that is tested with c#: The ATL project builds first, then the C# project, as the ATL DLL is a dependency of the C#...
2
by: Vish | last post by:
Hi all, I have a VS.NET (2005 BETA2) solution that has five winforms projects. Here are the details. Project-A (Main, startup project), references Project-B (class lib project) Project-B (Class...
2
by: Rudy Ray Moore | last post by:
How can I modify the project build order of a multi-project workspace under "Visual Studio .net 2003 7.1 c++"? I tried to modify the .sln by hand to influence the build order, but it didn't seem...
1
by: Jerad Rose | last post by:
Hello, I have searched all over for the answer to this, to no avail. I have a web project already set up and running on a remote server, that I created from my home computer. I am now trying...
11
by: Dave | last post by:
I copied the project files from an ASP.NET project on one computer and want to create the project on another computer, There is no connection between the two computers so I simply copied the...
4
by: Brad | last post by:
I'm not one to rant or flame....so please excuse me while I do so for this once. I've now spent a bit of time working with VS2005 beta 2 to see how it functions for web development, especially how...
29
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. How do I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.