Re: System.Xml.Schema in VC++ 6.0
From: SS (sri_at_iwon.comdontspam)
Date: 03/15/05
- Next message: Tim Hitch***: "defaultlib conflicts/unresolved _CrtDbgReport whn mixed mode"
- Previous message: Felix I. Wyss: "VC++2003: Methods implemented outside class body are never inlined for templates that are instantiated with __declspec(dllimport)"
- In reply to: William DePalo [MVP VC++]: "Re: System.Xml.Schema in VC++ 6.0"
- Next in thread: William DePalo [MVP VC++]: "Re: System.Xml.Schema in VC++ 6.0"
- Reply: William DePalo [MVP VC++]: "Re: System.Xml.Schema in VC++ 6.0"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Mar 2005 13:49:05 -0800
I tried your example but it did not work until I used "/codebase" like this:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\regasm
C:\work\learn\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll
/tlb:C:\work\learn\CallDotNetDLL\ClassLibrary1Lib.tlb /codebase
file:///C:\work\learn\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\regasm
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll
/tlb:C:\work\learn\CallDotNetDLL\mscorlib.tlb /codebase
file:///C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll
"William DePalo [MVP VC++]" wrote:
> "Maansi Sanghi" <maansisanghi@abosoftware.com> wrote in message
> news:ulst9oxHFHA.236@TK2MSFTNGP14.phx.gbl...
> > (3) This is the solution i was thinking of.
> >
> >
> >
> > 1. Create .NET DLL use regasm for creating Use
> > the
> > COM object
> > using managed class ----> a COM object from -----> from the
> > unmanaged code
> > System.Xml.Schema .NET dll
> > of legacy application.
> >
> >
> > (4) I am not sure if this solution would work. Have not been able to
> > develop
> > a proof of concept as yet for the above approach.
>
> I am happy to report that it works as doc'd. :-)
>
> With VS.Net 2003 I created this toy class in C#
>
> using System;
> using System.Runtime.InteropServices;
>
> namespace ClassLibrary1
> {
> [ClassInterface(ClassInterfaceType.AutoDual)]
> public class Class1
> {
> public Class1()
> {
> }
>
> public void SayHello()
> {
> Console.WriteLine("C# says hello!");
> }
> }
> }
>
> Note that if your class doesn't have a dual interface you'll need to talk to
> it via IDispatch. Yuck!
>
> Then I registered the assembly and created a type library from it with the
> command
>
> regasm /tlb:ClassLibrary1Lib.tlb ClassLibrary1.dll
>
> With VC++ 6.0 I created this toy application which used the compiler's
> import facility to read the type library and create the wrapper.
>
> #include <windows.h>
> #import "mscorlib.tlb" raw_interfaces_only
>
> using namespace mscorlib;
> #import "ClassLibrary1Lib.tlb"
> using namespace ClassLibrary1;
>
> int main()
> {
> CoInitialize(0);
>
> _Class1Ptr class1(__uuidof(Class1));
>
> class1->SayHello();
>
> CoUninitialize();
> return 0;
> }
>
> I put the C# assembly in the same directory as the executable and ran it. C#
> speaks.
>
> Regards,
> Will
>
>
>
>
- Next message: Tim Hitch***: "defaultlib conflicts/unresolved _CrtDbgReport whn mixed mode"
- Previous message: Felix I. Wyss: "VC++2003: Methods implemented outside class body are never inlined for templates that are instantiated with __declspec(dllimport)"
- In reply to: William DePalo [MVP VC++]: "Re: System.Xml.Schema in VC++ 6.0"
- Next in thread: William DePalo [MVP VC++]: "Re: System.Xml.Schema in VC++ 6.0"
- Reply: William DePalo [MVP VC++]: "Re: System.Xml.Schema in VC++ 6.0"
- Messages sorted by: [ date ] [ thread ]