473,480 Members | 2,374 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to address C++/CLI managed/unmanaged from C#?

3 New Member
My attemption with MS Visual Studio 2008 SP1.
Compilng/linking is OK. But the run of Main.exe results in FileNotFoundException (HRESULT: 0x8007007E) in TestUnmanaged.Main.
Expand|Select|Wrap|Line Numbers
  1. // cl /clr /LN Sub.cpp
  2. using namespace System;
  3. #pragma unmanaged
  4. void Dummy () {;}
  5. #pragma managed
  6. namespace MySubSpace {
  7.   ref class Sub1 {
  8.     public:
  9.       void SaySub1 (String ^name) {
  10.         Console::WriteLine ("Sub1 says : {0}", name);
  11.         Dummy ();
  12.     }
  13.   };
  14. }
  15. // csc Main.cs /addmodule:Sub.netmodule /platform:x86
  16. using System;
  17. using MySubSpace;
  18. public class TestUnmanaged {
  19.   public static void Main () {
  20.     Sub1 s1 = new Sub1();
  21.     s1.SaySub1 ("from Main");
  22.   }
  23. }
  24.  
Main.exe runs successfully if four lines in Sub.cpp with "pragma" and "Dummy" are commented out and "cl /clr:safe /LN Sub.cpp" is applied.
Dec 13 '10 #1
3 1919
Christian Binder
218 Recognized Expert New Member
I dn't know much about it, but I know, there's an unsafe keyword in c#, maybe you have a look at it

msdn 1
msdn 2
Dec 14 '10 #2
RostKudr
3 New Member
Thanks, Christian. But not any of the manipulations with "unsafe" in Main.csc prevents the exception.
I've tried:
1. public unsafe static void Main ()
2. csc Main.cs /addmodule:Sub.netmodule /platform:x86 /unsafe+
3. 1st and 2nd together.

The exception throws even if there is only one line in the method Main: Sub1 s1;
Dec 14 '10 #3
RostKudr
3 New Member
The problem is soldved in MS Visual Studio 2010 with applying csc compiler's key /unsafe
Dec 17 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2836
by: _BNC | last post by:
I've been adapting an older unmanaged C++ legacy app to C#---with limited success. The original app made use of an older, but straightforward, C DLL that worked efficiently under the VC++ 6 model....
0
1278
by: Nick | last post by:
Replying to x-post "Nick" <someone@somewhere.com> wrote in message news:ehLJlC52EHA.1564@TK2MSFTNGP09.phx.gbl... > Hi all, > > Using the .NET fx configuration utility, mscorcfg is it possible...
4
2144
by: | last post by:
I am stuck in a situation and I do believe that this should work, but it doesn't. I have a unmanaged dll, that uses MFC. This works great. Now I recompile the unmanaged dll so it contains...
3
1510
by: JoeProgrammer | last post by:
A couple of questions re. managed vs. unmanaged code. 1. I know this depends on the app, but how much faster is unmanaged code vs. managed code? Is there an average figure for this? 2. Is it as...
3
2624
by: Steve | last post by:
I have former VC++ 6.0 application which was ported to .NET. Now we continue to develop this app under VS.NET. The app now contains both managed and unmanaged classes. Now I have a problem with...
13
2222
by: DD | last post by:
I'm puzzled how to mix managed/unmanaged C++ in the following scenario: Unmanaged ------------ Callback listener class with method that should call an event in managed Form1. Initialization...
6
1438
by: nicolas.hilaire | last post by:
Hi all, i'm not totally clear with some concepts about managed and unmanaged code. I'm asking myself some questions : - i've a MFC app, i want to use the framework dotnet by switching to...
6
1607
by: Vijay | last post by:
Hi, I am faced with the following common managed/unmanaged C++ interop problem: - I have a .NET form that acts as a front end GUI to a processing engine in the background. The processing...
7
4457
by: A n g l e r | last post by:
Hi all. Can you please tell me if you have any problems to use managed C++ DLL libraries that wrap some code from unmanaged external DLL 32 bit libraries? If you called such managed 32 bit DLL...
0
1978
by: hanthehead | last post by:
In order to use a C# dll from our unmanaged C++ project I have created a mixed managed\unmanaged c++ dll. This dll is passed an unmanaged class which contains vector<CDBRecord> m_vecRecords member...
0
6915
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
7054
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7097
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...
1
6750
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...
1
4794
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3003
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2993
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
567
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.