|
Two options I can think of: first, to use side-by-side assemblies[^] to produce an isolated application. Second, to use the CLR Hosting[^] APIs to host the .NET Framework in your C++ application.
The second option looks like a lot of work, so I'd look into the first technique first. However, if you need it to work on Windows 2000 or earlier, I think it'll have to be the second.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Just tried your "CLR Hosting" suggestion: I looked at the "CLR Hosting Sample [^]" at the bottom of the link you suggested, slightly modified it and, it now works fantastic, without any additional registering.
Thank you!
--
Affordable Windows-based CMS: www.zeta-producer.com
|
|
|
|
|
Uwe, here's a thought, create an CCW a la my article[^], but you could control the registration from your application with the command line tool Regasm.exe[^], this way you could unregister it if you wanted (this idea seems brittle though). Also, CLR Hosting would be an interesting mechanism to consider as well. I've been wanting to write an article cover this topic, maybe I can sit down over the holiday weekend and put some notes together for it.
[EDIT]
You may also want to look into using the Tlbexp.exe[^] as it will generate the type library for you, however it won't register the assembly as regasm.exe will above.
[/EDIT]
- Nick Parker My Blog | My Articles
|
|
|
|
|
That would be great! Thanks for your feedback Nick, I will try out and post my results.
--
Affordable Windows-based CMS: www.zeta-producer.com
|
|
|
|
|
Both Mike's and Nick's answers are correct, but I wanted to explain what #import - the way you're using it - is. It serves two purposes - including assembly references in Managed C++ and importing typelibs, which generates a header and allows you to specify options for how that header file is generated.
Even if you have a typelib a la regasm.exe /tlb MyAssembly.dll and import that (as I did in my Java/.NET interop article), the classes still need to be registered. A typelib - as I'm sure you know - only describes types, nothing more.
If you go with Mike's approach about using manifests and don't want to register the components to be used by other COM clients (although, since that is the easiest, ask yourself "why not?". there's lots of "private" COM components registered on your system), understand that it'll only work on XP and newer and make sure that down-level platforms get a user-friendly error for when that type won't be found (off-hand, I'd bet you'd get either a TypeLoadException or TargetInvocationException ).
Hosting the CLR is another good idea and isn't too much work for the basic functionality.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
Uwe Keim wrote:
The guy metions a function getDllClassObject, which must be written by the autor of the book he mentions. Since I don't have the book, maybe I should buy it? Or do you know how the function probably works?
No it's probably just a VB wrapper around the native call, he is refering to DllGetClassObject[^] which you can implement yourself. It's returning a class factory based on the CLSID of the coclass and the interface being requested.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Sounds reasonable, thanks! Do you know any way to implement this function (DllGetClassObject ) from a managed COM DLL?
E.g. I once wrote a managed COM DLL where I applied the [System.Runtime.InteropServices.ComRegisterFunctionAttribute()] to a function to provide the registering functionality.
So I guess there must be a similar attribute or something like that in the System.Runtime.InteropServices namespace?!?
--
Affordable Windows-based CMS: www.zeta-producer.com
|
|
|
|
|
Uwe Keim wrote:
Sounds reasonable, thanks! Do you know any way to implement this function (DllGetClassObject) from a managed COM DLL?
You can simply create a class factory in your .NET code. Make sure you just return an interface pointer to the created class. You can use the standard C-style casting mechanism as well.
private IFun GetFunObject(string strType)
{
IFun iFun;
if(string.Compare(strType, "SomeClassName") == 0)
{
iFun = (IFun) new Fun();
}
return iFun;
}
interface IFun
{
void HaveFun();
}
class Fun : IFun
{
void HaveFun()
{
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Remember that VB6 (or older) != VB.NET...er, <> VB.NET! Completely different runtime.
GetDllClassObject has to be a natively exported function, just like DllRegisterServer , DllUnregisterServer , etc. This isn't possible with the managed compilers, though if you wrote your own compiler you could inject implementations or relocate calls to a bootstrap DLL (this is actually how VB6 and many other executables work - the entry point is actually a redirect to another library that calls back into the PE/COFF executable).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I need to show a drawing surface that is the same size as the default printer page but which is a user control. Then I need to scale it for better viewing. What would be the best approach to take on this one? I am a little bit stymied.
Thanks
|
|
|
|
|
|
Does anyone know how to get the commandline parameters of an externally created process?
The Process class gives you the StartInfo property which includes "Arguments". This works great if I want to start my own process. However, I've found that it never contains the arguments used to start an external process that my program didn't start. It's always empty.
In C, there's a Win32 call for GetCommandLine() which would work great... except it only works for the calling process, not an external one.
SysInternals' "Process Explorer" does this without any trouble for any process so I know it can be done. Any help? I don't care if it's C/C++, VB, VB.NET, or C#.
Thanks
|
|
|
|
|
Did you ever figure this out ?
|
|
|
|
|
Yeah, I ultimately did in C++. I wrote a wrapper in ATL COM so I could easily use it in a C# project I was working on at the time. Unfortunately the hard drive it existed on was lost when the project was shelved a couple years back. I MAY have a backup still on another drive at the office. I can dig that up for you if you really need it, but it will need to wait until Monday. If you can't, then look into examining the PEB (process environment block). I think it had something to do with NtQueryInformationProcess but I'm not sure. You can get the processID of the process you want to query with the .NET classes, then jump into the lower level API calls to get the rest.
Hmmm, maybe there's an actual article in there for CP. I hadn't thought about that before.
|
|
|
|
|
hi,
how to use datagrid for making invoice and purcase orders and so on. any one help to me. if possible with small sample.
Thanks in advace!
Have A Nice Day!
Murali.M
|
|
|
|
|
It's very tough to get a ready made customizable Grid. What you need to do is, play around with your logic.
I wrote an article on DataGrid formattings. This will help you to customize your figures(numbers) in desided fasion. apart from this please check this link, which contain lot of tips and sample tutorials which will guide you to reach your place.DataGrid Gal
Sreejith Nair
[ My Articles ]
|
|
|
|
|
This is a great Windows Forms FAQ and has a few examples of datagrid formatting:
WinForms FAQ[^]
Gary
While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'
- Dilbert
|
|
|
|
|
Hi,
I remember that there's an object stream writer in Java which makes it easy to save objects into files. What class is this in C#?
Rafferty
|
|
|
|
|
You can use the BinaryWriter, or, for a higher level solution, BinaryFormatter with the [Serializable] attribute on the class.
Yes, even I am blogging now!
|
|
|
|
|
How i can handle request from client and repond to client in Microsoft IIS 5.0 or more? What do i need? Or some information? Thanks
Nothing
|
|
|
|
|
|
That's a very generic question. A "request" can mean anything, a web serivce, web page, authentication, ...
You'll have to be MUCH more specific about what you want to do before anyone can help you.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It's like program a windows service that can get the request from user like "username","password" and this service will get some information from internet and send to that user.
Nothing
|
|
|
|
|
You don't need a service for that, just a normal ASP.NET project will work. Still, your requirements are very vague...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|