|
Its just a matter makking a few .NET wrapper methods in MC++, and then just call them from your C# code.
Example:
I compile the dot.exe from GraphViz in normal C/C++. To make it a .NET dll all I did was to wrap the main function in a static method in a managed class and compile to dll. The only CLR options you need to set is on the wrapper file.
<a TITLE="See my user info" href=http:
|
|
|
|
|
Thnx for your answer, but I'm still a bit confused...
Do you have a more detailed example or some links were wrapping is explained. My problem is, that I am not really familiar with c++, but I have to add some c++ functions...
Example:
I only define a class in c++ and compile it to a dll under VC 6.0.
Class xyz
{
xyz()
{printf("Hallo");}
int add(int a, int b)
{
return a+b;
}
}
How can I call this class out of c#? How can I create an instance of xyz or call the add function?!
Please, I really need some help!
|
|
|
|
|
Hey all. I've written a Windows Service using Visual Studio 2003, added an Installer to it using the 'Add Installer' verb, and verified that the 'RunInstaller' attribute was present, and set to True. Check, check, and check. Yet, when I try to install the stupid thing using InstallUtil.exe, I get the following error:
No public installers with the RunInstallerAttribute.Yes attribute could be found in...
Excuse me? Yes there are! Anyway, from searching Google, it almost looks like this might be a bug in VS 2003. Any ideas? If nothing else, does anybody know what keys I need to manually create in the registry to make it work?
Thanks in advance.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
Never mind. I just saw Paul Watsons post below. Problem solved.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
Jamie Nordmeyer wrote:
Never mind. I just saw Paul Watsons post below. Problem solved.
It is not all that obvious, especially since it says "it does not exist" instead of "it is there but wrong version buddy."
Paul Watson Bluegrass Cape Town, South Africa
brianwelsch wrote:
I find my day goes by more smoothly if I never question other peoples fantasies. My own disturb me enough.
|
|
|
|
|
Gotta love Microsoft and their WONDERFULLY informant error messages.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
Hi all,
Does anybody know if there are problems loading and assembly using the static 'Assembly.Load' or similar from a .NET COM+ component?
I have found that doing it my component wait as if it was in an infinite loop. I read only a line in the help about using the dinamic 'AppDomain.Load' inside these components. I did it and it works fine.
A second question would be now if it is possible load from the GAC using AppDomain.Load, providing an assembly partial name.
TIA
Fennnan
|
|
|
|
|
Here's waht I use - it also late binds to a Enterpise Serviced component in COM+ - and calls the VersionProperty on the class represented by the Prog ID...
// Create a Crypto Manager - Create the Type locally
Type tEngine = Type.GetTypeFromProgID("Collaborator50.EQOSCollaborator", vstrAppServer, true);
// Create an Instance of Type
objEngine = Activator.CreateInstance(tEngine);
// Make the call
object objVersion = tEngine.InvokeMember(
"Version",
BindingFlags.Public | BindingFlags.GetProperty,
null,
objEngine,
null);
|
|
|
|
|
It's possible I didn't explain myself well: Inside an Enterprise Services component I need to invoke, using reflection, a .NET class. The class I'm instanciating has not a COM Wrapper so has not a ProgId, so I can't load it using GetTypeFromProgID.
Using the static method Assembly.LoadWithPartialName, I don't need to care about version, culture, etc. The problem is it stops my COM+ component (an Enterprise Service class), as if it was in an infinite loop.
Then I found AppDomain.Load. This method is not static, so I use AppDomain.CurrentDomain in order to call the method. And it works! . From Microsoft documentation about this method it says: "This method is defined for interoperability callers who cannot call the static Load method." However, is the only reference I've found all around about this topic.
If it works, why am I asking for? Cause I can't load assemblies with partial name using this method
I hope you're not being bored with my explanation!
Cheers
|
|
|
|
|
Not bored - just nonplussed. We do this the 1st way you talekd about a lot from Serviced components and it works fine.
|
|
|
|
|
How do you do component licensing in .NET - i.e. so that people must have a license file to use your control in the design environment?
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
I have installed the .NET framwework SDK. But whenever I try to manually compile code it can't find csc.exe. Is there some way to register it so i can use it right from a command prompt? I can only get it to work if i am running it from it's root directory.
Steve
McLenithan
Is Bert Evil?
|
|
|
|
|
I guess that, because you haven't installed the VS.NET IDE, you don't have the vcvars32.bat which sets all paths.
Here it is, just in case :
---- BEGINS HERE ----
@SET VSINSTALLDIR=C:\vc7\Common7\IDE
@SET VCINSTALLDIR=C:\vc7
@SET FrameworkDir=C:\WINNT\Microsoft.NET\Framework
@SET FrameworkVersion=v1.0.3705
@SET FrameworkSDKDir=C:\vc7\FrameworkSDK
@rem Root of Visual Studio common files.
@if "%VSINSTALLDIR%"=="" goto Usage
@if "%VCINSTALLDIR%"=="" set VCINSTALLDIR=%VSINSTALLDIR%
@rem
@rem Root of Visual Studio ide installed files.
@rem
@set DevEnvDir=%VSINSTALLDIR%
@rem
@rem Root of Visual C++ installed files.
@rem
@set MSVCDir=%VCINSTALLDIR%\VC7
@rem
@echo Setting environment for using Microsoft Visual Studio .NET tools.
@echo (If you also have Visual C++ 6.0 installed and wish to use its tools
@echo from the command line, run vcvars32.bat for Visual C++ 6.0.)
@rem
@REM %VCINSTALLDIR%\Common7\Tools dir is added only for real setup.
@set PATH=%DevEnvDir%;%MSVCDir%\BIN;%VCINSTALLDIR%\Common7\Tools;%VCINSTALLDIR%\Common7\Tools\bin\prerelease;%VCINSTALLDIR%\Common7\Tools\bin;%FrameworkSDKDir%\bin;%FrameworkDir%\%FrameworkVersion%;%PATH%;
@set INCLUDE=%MSVCDir%\ATLMFC\INCLUDE;%MSVCDir%\INCLUDE;%MSVCDir%\PlatformSDK\include\prerelease;%MSVCDir%\PlatformSDK\include;%FrameworkSDKDir%\include;%INCLUDE%
@set LIB=%MSVCDir%\ATLMFC\LIB;%MSVCDir%\LIB;%MSVCDir%\PlatformSDK\lib\prerelease;%MSVCDir%\PlatformSDK\lib;%FrameworkSDKDir%\lib;%LIB%
@goto end
:Usage
@echo. VSINSTALLDIR variable is not set.
@echo.
@echo SYNTAX: %0
@goto end
:end
---- ENDS HERE ----
Replace the FrameworkVersion variable with the appropriate value. Since you seem not to have the VS.NET IDE, in fact only a fraction of those variables are useful. For csc.exe, what's important to have is the PATH variable.
My recommendation is to directly add the appropriate paths in your user environment variables, from the OS config panel.
|
|
|
|
|
That is the weird thing I DID install VS.net. I don't know why it isn't working. But I will add that path variable like you suggested.
Thanks
Steve
McLenithan
Is Bert Evil?
|
|
|
|
|
1. It doesnt add the path by default (god knows why).
2. Windows operating systems still needs a reboot for PATH variables to take effect (no-one knows why).
Hey leppie! Your "proof" seems brilliant and absurd at the same time. - Vikram Punathambekar 28 Apr '03
|
|
|
|
|
The best way is to use the "Visual Studio.NET (2003) Command Prompt" in your Tools menu under "Start/Program Files/Visual Studio.NET". This will launch a command (cmd) window with all of the paths set etc. The nice thing is that they only exist for that session so you don't end up with masses of system or user path settings which is a bit Win95ey!!! (IMHO!!)
Shaun
|
|
|
|
|
leppie wrote:
It doesnt add the path by default (god knows why).
The old VS6 installation used to ask you if you wanted this to happen. I'm surprised they took this out in VS7 (I don't remember seeing that option in the install either...). But there's always the "Visual Studio Command Prompt" shortcut that VS.NET creates. I've put it on my shortcut bar for easy use
As for the .NET FrameworkSDK, it provides a 'corvars.bat' in the FrameworkSDK/bin directory that sets PATH to allow for easy usage of the compilers and tools that come with the SDK.
leppie wrote:
Windows operating systems still needs a reboot for PATH variables to take effect (no-one knows why).
The NT line doesn't require an OS reboot under these circumstances. When a new process starts, it gets its own copy of the current environment. This means that just the process will need to be restarted - not the whole OS. For instance, if you change PATH, all command lines you currently have open will continue to use the old PATH, but new ones you open will use the new PATH. You can force explorer to recognize new environment variable changes be using TaskManager to shut it down and restart it.
--
Russell Morris
"Have you gone mad Frink? Put down that science pole!"
|
|
|
|
|
Hi Steve,
You can use Start -> Programs -> Microsoft Visual Studio .NET -> Visual Studio .NET Command Prompt
(That will set all path variables necessary for .NET applications). Perhaps I think this is a batch file. We can copy necessary values and put them onto System Path as well. I have'nt tried that anyway, but should work too.
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
hi all,
the question is :
"Is there any support in .net to capture the ethernet packet moving on the network?"
regards
|
|
|
|
|
Somewere on this very site - name eludes me though
|
|
|
|
|
In my program ,I create a new Bitmap use
Bitmap bmp = new Bitmap(200,200);
and I use the GetPixel() method to get the color info.
the result is [Color A = 0 R = 0 B = 0 G = 0]
and then I save it use the bmp.Save("C:\\ss.bmp",ImageFormat.Bmp)
but when I reload it Use the Image.FromFile()
I found that the color change to
[Color A = 255 R = 0 B = 0 G = 0]
how can I resolve this problem?
|
|
|
|
|
I'm not sure, whether bmp file format does support alpha channel...
Try using other ImageFormat (maybe Png format can be better)
i'm only pointer to myself
|
|
|
|
|
Hi folks,
I'm working on a project using both clr and non clr-Modules. I try to load a C#-assembly dxnamically from a c++Module translated with the clr option. For that I'm using the .Net-Assembly class (System.Reflection.Assembly). In some cases I cannot call the function I'd like to. That depends on wheter some Objects are instantiated whithin it or not.
Here the code of the function I try to call via Reflection:
This works :
/////////////////////////
public void Init()
{
//Doc.Document doc = new Doc.Document
String txt = "hello";
}
/////////////////////////
this doesn't
/////////////////////////
public void Init()
{
Doc.Document doc = new Doc.Document;
String txt = "hello";
}
/////////////////////////
In case the critical line is there, I cannot even debug into the function, making it hard to find the error. Any Ideas ?
|
|
|
|
|
You're right, but I just wrote it down wrong from my memory, so the paranthesises are not the problem. The assemblies/modules all compile properly, so it's not a syntactical error. The assemblies/modules just do not work with each other. pitty
|
|
|
|
|
You're right, but I just wrote it down wrong from my memory, so the paranthesises are not the problem. The modules all compile properly, so it's not a syntactical error. The modules just do /do not work with each other depending on the code in the function called across the modules. pitty
|
|
|
|