473,396 Members | 1,707 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,396 software developers and data experts.

using a C++ library from C# - load error

i've been tearing my hair out over this for hours. i can reference a C++
library from my C# code on my dev machine, but when i copy the entire Debug
directory to another computer my code fails, giving a "Could not load file or
assembly <nameofC++library>...the application configuration is incorrect."

To repro, I first create a C++ CLR class library and add one class with a
simple function "int GetAge()" that returns the number 20. I then create a
Windows app with a form and a button on it that calls GetAge() and displays
the result in a message box. To reference the C++ library, I click on
References, Add Reference, Projects, and then the name of my C++ class
library project. The code works fine - debug and release - on my dev machine.
I copy the Debug (or Release) directory to an XP machine and run it; the form
pops up but as soon as I click the button (which calls into the C++ library)
it croaks. This is VS 2005, .net 2.0.

What am I doing wrong? My scenario couldn't be a simpler example of C++ and
C# playing nice together.
Dec 13 '07 #1
2 4920
i can email the whole solution to someone if it helps. the code is very short.

"jmagaram" wrote:
i've been tearing my hair out over this for hours. i can reference a C++
library from my C# code on my dev machine, but when i copy the entire Debug
directory to another computer my code fails, giving a "Could not load file or
assembly <nameofC++library>...the application configuration is incorrect."

To repro, I first create a C++ CLR class library and add one class with a
simple function "int GetAge()" that returns the number 20. I then create a
Windows app with a form and a button on it that calls GetAge() and displays
the result in a message box. To reference the C++ library, I click on
References, Add Reference, Projects, and then the name of my C++ class
library project. The code works fine - debug and release - on my dev machine.
I copy the Debug (or Release) directory to an XP machine and run it; the form
pops up but as soon as I click the button (which calls into the C++ library)
it croaks. This is VS 2005, .net 2.0.

What am I doing wrong? My scenario couldn't be a simpler example of C++ and
C# playing nice together.
Dec 14 '07 #2
i solved it by creating a setup program. you can't xcopy an app that uses a
managed C++ library. apparently additional DLLs are needed beyond the .net
framework and the DLLs produced by your app. you need msvcm80.dll and a few
other DLLs for this interop to work.

"jmagaram" wrote:
i can email the whole solution to someone if it helps. the code is very short.

"jmagaram" wrote:
i've been tearing my hair out over this for hours. i can reference a C++
library from my C# code on my dev machine, but when i copy the entire Debug
directory to another computer my code fails, giving a "Could not load file or
assembly <nameofC++library>...the application configuration is incorrect."

To repro, I first create a C++ CLR class library and add one class with a
simple function "int GetAge()" that returns the number 20. I then create a
Windows app with a form and a button on it that calls GetAge() and displays
the result in a message box. To reference the C++ library, I click on
References, Add Reference, Projects, and then the name of my C++ class
library project. The code works fine - debug and release - on my dev machine.
I copy the Debug (or Release) directory to an XP machine and run it; the form
pops up but as soon as I click the button (which calls into the C++ library)
it croaks. This is VS 2005, .net 2.0.

What am I doing wrong? My scenario couldn't be a simpler example of C++ and
C# playing nice together.
Dec 14 '07 #3

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

Similar topics

0
by: Simon | last post by:
Hello. I wanna use my dynamic shared library(built with C language) with php script. (PHP version is 4.0.6) So I making a shared library(*.so) in Solaris environment(2.7) and it is successful....
6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
0
by: Peter | last post by:
When I issue call sqlj.install_jar('file:///f:/jars/mail.jar','MAIL'); I get the messages SQL4301N Java or .NET interpreter startup or communication failed, reason
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
2
by: Mr Wizard | last post by:
I am going through the front controller http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpFrontControllerInASP.asp and all works well except when the server.transfer...
1
by: Jim | last post by:
Have fully operational software package developed on VB.NET that worked until Jan 1 2003, with early stage deployments on Oct 10, Oct 23, Nov 11, Dec 12 and Dec 30. When attempted final...
7
by: Tiraman | last post by:
Hi , I have 2 Questions About Using Enum 1) i have the following Enum under my class but if i need to use it i must use it like this ConstantsFileSystem.CREATE_FILE how can i use it just...
0
by: =?Utf-8?B?UmFodnlu?= | last post by:
Hi All; I am writing a COM interface that will need to be called from VBScript (Legacy App). I need to return a recordset to the calling app. I am using ADODB to populate the recordset and...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.