|
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!
|
|
|
|
|
So I guess if I am using 'normal' and Managed code I just have to install the framework?
|
|
|
|
|
Yes. If your application uses both; the framework has to be installed.
Something that just came to mind though. If you have it set so it can *optionally* load the managed code (ie it loads the managed code on demand and doesn't have anything about the managed code compiled aside from a GUID), then the framework could possibly be an option for the client as well... But if they decide to use it they will need the framework.
James
Simplicity Rules!
|
|
|
|
|
BTW, hopefully this time next year or the year after we can assume that many will have the framework installed so the fact there is a 20MB download won't be as much of an issue.
James
Simplicity Rules!
|
|
|
|
|
The redistributable is already part of windows update
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|