Linking Managed C++ library to csharp ASP.NET application 
Author Message
 Linking Managed C++ library to csharp ASP.NET application

I have a couple of C libraries that are being wrapped in a C++ managed
class.  This works great, and on my development machine I can add it as a
reference in Visual Studio .NET.  After I do that, I can use it in my CSharp
codebehind files in its namespace.

However, when I need to move it to a staging type server, without a copy of
Visual Studio .NET, I am having problems.  It is looking for my two .dlls at
the path they are on my dev machine.

I have looked up how to compile from the command line, and gotten it to
actually compile all my codebehinds, except for the ones needing those two
dlls, where it promptly tells me:

CLASSES\Foo.cs(107,10): error CS0234: The type or namespace name
'NetFunctions' does not exist in the class or namespace 'Foo' (are you
missing an assembly reference?)

I can understand this, as I have not been able to get any sort of reference
command to work.  I have tried csc with the argument /reference:Foo.cs,
which doesn't generate any new errors, but also doesn't fix the problem.

What I need to be able to do is find a way for me to reference these .dlls
in the compile.  I would have thought I could reference them on the command
line at csc, but it appears not.  I may be doing that wrong, I suppose.

The only things installed on this staging server is Windows 2000/IIS 5.0,
and the .NET framework beta 2.  I can compile anything that doesn't require
the managed c++ functions.

If  you have any advice or comments I'd greatly appreciate it.  I can post
more information if it is desired, but I'm not sure what is relevent to my
situation that I haven't explained above.

Thanks,

Mark E. Scott Jr.



Wed, 26 May 2004 14:15:59 GMT  
 Linking Managed C++ library to csharp ASP.NET application



Quote:
> I have a couple of C libraries that are being wrapped in a C++ managed
> class.  This works great, and on my development machine I can add it as a
> reference in Visual Studio .NET.  After I do that, I can use it in my
csharp
> codebehind files in its namespace.

> However, when I need to move it to a staging type server, without a copy
of
> Visual Studio .NET, I am having problems.  It is looking for my two .dlls
at
> the path they are on my dev machine.

> I have looked up how to compile from the command line, and gotten it to
> actually compile all my codebehinds, except for the ones needing those two
> dlls, where it promptly tells me:

> CLASSES\Foo.cs(107,10): error CS0234: The type or namespace name
> 'NetFunctions' does not exist in the class or namespace 'Foo' (are you
> missing an assembly reference?)

> I can understand this, as I have not been able to get any sort of
reference
> command to work.  I have tried csc with the argument /reference:Foo.cs,
> which doesn't generate any new errors, but also doesn't fix the problem.

> What I need to be able to do is find a way for me to reference these .dlls
> in the compile.  I would have thought I could reference them on the
command
> line at csc, but it appears not.  I may be doing that wrong, I suppose.

First, build off your managed C++ libraries. Then, when compiling your C#
dlls, use the /r:<YourMCPPLibHere.dll> switch to the command line. Remember
that you compile all your C# files into a single assembly in a single pass:
just pass the names of all your .CS files at the end of the command line of
csc.exe. Or use wildcards, such as:

csc.exe /r:<YourMCPPLibHere.dll> /t:library /out:YourCSLib.dll CLASSES\*.cs

--
Tomas Restrepo



Wed, 26 May 2004 21:50:10 GMT  
 Linking Managed C++ library to csharp ASP.NET application
Hi Mark,
In the C# project settings, when you highlight the reference in the Solution
Explorer, you should be able to change the property of the reference to Copy
Local = true. This in essence renders the Path dependency to be unimportant,
because when the application runs, if the MC++ dll is in the same folder or
somewhere on the %PATH% for the machine, the .Net loading mechanism will
find the dll and load it for the exe. Then you arent bound up by VS.Net at
all. When you go to copy it to another machine or, as you mention, a staging
area, since the property for the reference is to use the Local (in
folder/path) copy of the dll the component will run as expected.

--
regards,
Robert Svilpa
Software Design Engineer in Test
Managed Extensions for C++
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.



Quote:
> I have a couple of C libraries that are being wrapped in a C++ managed
> class.  This works great, and on my development machine I can add it as a
> reference in Visual Studio .NET.  After I do that, I can use it in my
csharp
> codebehind files in its namespace.

> However, when I need to move it to a staging type server, without a copy
of
> Visual Studio .NET, I am having problems.  It is looking for my two .dlls
at
> the path they are on my dev machine.

> I have looked up how to compile from the command line, and gotten it to
> actually compile all my codebehinds, except for the ones needing those two
> dlls, where it promptly tells me:

> CLASSES\Foo.cs(107,10): error CS0234: The type or namespace name
> 'NetFunctions' does not exist in the class or namespace 'Foo' (are you
> missing an assembly reference?)

> I can understand this, as I have not been able to get any sort of
reference
> command to work.  I have tried csc with the argument /reference:Foo.cs,
> which doesn't generate any new errors, but also doesn't fix the problem.

> What I need to be able to do is find a way for me to reference these .dlls
> in the compile.  I would have thought I could reference them on the
command
> line at csc, but it appears not.  I may be doing that wrong, I suppose.

> The only things installed on this staging server is Windows 2000/IIS 5.0,
> and the .NET framework beta 2.  I can compile anything that doesn't
require
> the managed c++ functions.

> If  you have any advice or comments I'd greatly appreciate it.  I can post
> more information if it is desired, but I'm not sure what is relevent to my
> situation that I haven't explained above.

> Thanks,

> Mark E. Scott Jr.




Mon, 31 May 2004 03:49:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Linking Managed C++ library to csharp ASP.NET application

2. Managed C++ DLL linked to static (C++) libraries (VSNet Beta 2)

3. From C++ console DOS lib to .NET managed component library

4. Inaccessable .Net classes from C++ managed libraries.

5. threading Question about CSharp with ASP.net

6. CSharp + ASP.net

7. ASP.NET application with Windows.NET RC1

8. Managed C++ call from CSharp

9. How to call VB.net and ASP.net programs in MFC?(or,asp call vc)

10. Inherit unmanaged c++ classes from .Net platform (managed c++ or c#)

11. Convert Conventioal C++ Program to Managed C++ of Visual C++.NET

12. debugging unmanaged c++ from a managed c++ class library

 

 
Powered by phpBB® Forum Software