|
Albert Pascual wrote:
have received an email from MS letting me know its fixed in the next version of the compiler!
That's cool! I didnt think MS would this responsive
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I am looking some clarifications for the use of IJW and p/Invoke.....
I have a DLL which is written in Visual C++ (NOT a COM component). I am planning to use that from Visual Basic.NET. Infact there is a VB code earlier written to call that DLL. Now the application is being rewritten in VB.NET and I want use that DLL. What are the ways I can use that DLL?
I found the following ways (I am not 100% what I found are correct or not)
1) Use P/Invoke in Visual Basic.NET and call the functions in the DLL
2) Recompile the C++ DLL using IJW switch so that it will be a managed one. Since my VB.NET code is a managed one, I can access that..Is this approach correct? or do I need to write wrappers over managed C++ obtained after compiling with IJW switch to use in VB?(I heard that after compiling with IJW you can use only with managed C++ and not with any code written using other languages like VB.NET or C#)
Whar is the performance difference between IJW and P/Invoke ?
Can anyone give me an answer?
Thanks in advance,
Madhu.
|
|
|
|
|
Madhu C wrote:
Recompile the C++ DLL using IJW switch so that it will be a managed one
Very confusing! What's an IJW switch?
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
He is talking about the /clr switch in C++ compiler options. (BTW. He posted the same question to DOTNET mailing list)
|
|
|
|
|
Rama Krishna wrote:
He is talking about the /clr switch in C++ compiler options
Oh! Thanks. That explains it
Rama Krishna wrote:
He posted the same question to DOTNET mailing list)
I am not a member there
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I was talking about the /clr switch in C++ compiler options.
BTW I got some really good answers about IJW and P/Invoke from DOTNET mailing list.
Madhu.
|
|
|
|
|
Madhu _Cheriyedath wrote:
I was talking about the /clr switch in C++ compiler options.
Thanks.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I have a C# front end DLL with a namescape FrontEnd
From managed C++ I run the Dll and it works all good. Now I want to call a public function of one of the classes. In Managed C++ I have:
FrontEnd::MyClass * pMyclass;
That works fine but I cannot call any public class:
pMyclass::MypublicFunction(arg1, arg2);
Compiler error:
error C2039: MypublicFunction: is not a member of 'FrontEnd::pMyclass'
Any idea?
Al
|
|
|
|
|
Fixed!
namespace FrontEnd must be reserved. I changed the name and it works just fine!!
Now I can create C# front ends and still use MC++ for my programs!! Awesome.
I am still waiting for Microsoft to create a UI for Forms for MC++
Al
|
|
|
|
|
I have the following method that instantiates a specified class in a given .NET assembley with specified activation attributes.
HRESULT LoadCORClassEx(
BSTR AssemblyName, /* mscorlib */
BSTR typeName, /* System.Text.RegularExpressions.Regex */
REFIID riid,
void **ppv,
SAFEARRAY *args)
{
HRESULT hr = S_OK;
if(ppv == NULL) return E_POINTER;
*ppv = 0;
/*** debug ***/
VARIANT var;
HRESULT hresult;
long ix = 0;
VariantInit(&var);
hresult = SafeArrayGetElement( args, &ix, &var);
if(FAILED(hresult)) return hresult;
/*** end debug ***/
CComPtr<_ObjectHandle> spHandle;
spHandle.p = g_host.spDefaultAppDomain->CreateInstance_2(
AssemblyName,
typeName,
args);
CComVariant unwrapped;
unwrapped = spHandle->Unwrap();
if (unwrapped.vt != VT_UNKNOWN && unwrapped.vt != VT_DISPATCH)
return E_UNEXPECTED;
return unwrapped.punkVal->QueryInterface(riid, ppv);
}
I can get the contents of the args SAFEARRAY that is passed into this method into a variant -- shown in the debugger as {"abc" VT_BSTR} -- before the subsequent call to CreateInstance_2(), however, when I step into the call to CreateInstance_2(), the underlying raw_CreateInstance_2() call in mscorlib.tli blows up .
Can anyone see what I am doing wrong here? I tried adding the save /*** debug ***/ code to mscorlib.tli in order to peek at the content of the SAFEARRAY being passed for activation attributes, but the debugger seems to ignore the added code...
Thanks for any insights!
--
Roy
|
|
|
|
|
WEll! i may not be very clear about the question i am asking myself! but what i wanna ask is that what are the different ways to make the Dll's in .NET and are the DLL's in the .NET can be managed ones!
|
|
|
|
|
If you have VS.NET, then simply use the wizard to create a Managed C++ Class Library and that's it. Just don't give a main or a wmain anywhere
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Is this safe? I have found that wchar_t* variables are implicitly cast to __gc String* variables. I hope this is okay and does not have any hidden issues.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Makes sense to me, managed String and char types are unicode safe.
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
Makes sense to me, managed String and char types are unicode safe.
Whew! Nice to hear that
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I discovered that you cannot use #pragma unmanaged for a member function of a managed class, even though the member function uses only unmanaged calls. Thus I have concluded that you can use #pragma unmanaged only for unmanaged global functions or for unmanaged classes. But then, what's the bloody point, since unmanaged code will get compiled to native code anyway!
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Thats the whole point, you can call the x86 code from managed code
#pragma managed
public __gc class MyClass
{
void DoLotsOfUnmanagedThings()
{
unmanagedCall();
}
};
#pragma unmanaged
void unmanagedCall()
{
} James
Simplicity Rules!
|
|
|
|
|
Well, when it sees a fuilly unmanaged function, why doesn't it auto-apply #pragma unmanaged to that block?
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Don't know
I tricked you by letting you think I actually learned something when in reality i've been too busy sleeping and working on the screensaver
Oh and looking for good songs on mp3.com, here, here, and here.
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
Simplicity Rules!
Try saying that to Chris Losinger
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
James
Simplicity Rules!
|
|
|
|
|
Nish [BusterBoy] wrote:
Well, when it sees a fuilly unmanaged function, why doesn't it auto-apply #pragma unmanaged to that block?
1. Managed Code - Code that compiles into IL (atleast in the first version of CLR in the next version it would be possible to have IL unmanaged functions)
2. Unmanaged Code - Code that compiles into native processor's instructions
So you see there is nothing called an unmanaged function before anything gets compiled.
It is perfectly legal to have global functions in managed code. ILASM can create and use it( may be VB.NET).
|
|
|
|
|
Rama Krishna wrote:
So you see there is nothing called an unmanaged function before anything gets compiled.
That's what I thought too, till it disallowed me from using the #pragma unmanaged directive to a function
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
If i write a program in UNMANAGED VC++ 7.0 using ATL 7.0 and\or MFC 7.0, do I have to install the .Net framework or can I just supply the required ATL\MFC DLL's to the users machine?
Is installing the framework just for Microsoft's CLR?
|
|
|
|
|
If its unmanaged you don't need the framework; only when you cross into managed code do you need the framework on the users machine.
James
Simplicity Rules!
|
|
|
|