RegFree Com with Microsoft Access 2003 (XP / NET 2.0)

P

Patrick Wolf

Hi,

I am trying very hard to use RegFree Com from Microsoft Access 2003 on XP
Pro .NET 2.0.
I made a class library project in VS 2005 C# (Service.cs & Assembly.cs).

When referencing in from a local installed Access it works fine.
When trying to run it from a different workstation where Test.API.COM.dll is
not registered it doesnt work.
When I put all files into the Office11 folder Access says on startup
"The application has failed to start because the application configuration
is incorrect.."

When I remove this line from the manifest Access starts again but it still
doesnt work to call Test.API.COM.dll
<typelib
tlbid="{2af5c211-13bf-43f9-b200-dce012140422}"
version="1.0.0.0" helpdir="" resourceid="0" flags="HASDISKIMAGE" />

Thank you very much for your help
Patrick Wolf
www.patrickwolf.net



----------------------------------------------------------------------------------------------
Service.cs (in VS 2005 project)
----------------------------------------------------------------------------------------------
using System.Runtime.InteropServices;

using Microsoft.VisualBasic;

namespace Test.API.COM

{

// [ComVisible(true)]

[ComClass(Service.ClassId, Service.InterfaceId, Service.EventsId)]

public class Service

{

#region "COM GUIDs"

public const string ClassId = "D50636AF-44BF-4A4C-BF41-713070D9ECA2";

public const string InterfaceId = "FBA843CB-D290-4C95-8D04-C72B51A29F06";

public const string EventsId = "491518C7-D50F-4A36-A490-75A93C168E44";

#endregion

public Service():base() {}


public string GetMe(string test){return "return value: " + test;}

}

}

----------------------------------------------------------------------------------------------
AssemblyInfo.cs (in VS 2005 project)
----------------------------------------------------------------------------------------------
.....
[assembly: ComVisible(true)]
[assembly: Guid("2af5c211-13bf-43f9-b200-dce012140422")]
.....

----------------------------------------------------------------------------------------------
MsAccess VBA Code
----------------------------------------------------------------------------------------------
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim d As Test_API_COM.Service
Set d = New Test_API_COM.Service

MsgBox (d.GetMe("HIPAT"))

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox err.Description & err.LastDllError & err.Source & err.Number
Resume Exit_Command0_Click

End Sub

----------------------------------------------------------------------------------------------
MSACCESS.EXE.CONFIG
----------------------------------------------------------------------------------------------
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>

----------------------------------------------------------------------------------------------
MSACCESS.EXE.MANIFEST
----------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="10.0.4302.0" processorArchitecture="X86" name="MSACCESS.EXE"
type="win32"
/>

<file name="Cafe.Amanda.API.COM.dll"
xmlns="urn:schemas-microsoft-com:asm.v1">
<typelib
tlbid="{2af5c211-13bf-43f9-b200-dce012140422}"
version="1.0.0.0" helpdir="" resourceid="0" flags="HASDISKIMAGE" />
<comClass
clsid="{D50636AF-44BF-4A4C-BF41-713070D9ECA2}"
threadingModel="Apartment"
tlbid="{2af5c211-13bf-43f9-b200-dce012140422}"
progid="Cafe_Amanda_API_COM.Service"
name="Cafe_Amanda_API_COM.Service"/>
</file>
</assembly>

----------------------------------------------------------------------------------------------
 
P

Phil Wilson

I believe the system event log contains a more specific description of the
error in these situations. It tells you the line number and maybe other
info. Look for SideBySide entries.
--
Phil Wilson
[Microsoft MVP-Windows Installer]
Patrick Wolf said:
Hi,

I am trying very hard to use RegFree Com from Microsoft Access 2003 on XP
Pro .NET 2.0.
I made a class library project in VS 2005 C# (Service.cs & Assembly.cs).

When referencing in from a local installed Access it works fine.
When trying to run it from a different workstation where Test.API.COM.dll
is not registered it doesnt work.
When I put all files into the Office11 folder Access says on startup
"The application has failed to start because the application configuration
is incorrect.."

When I remove this line from the manifest Access starts again but it still
doesnt work to call Test.API.COM.dll
<typelib
tlbid="{2af5c211-13bf-43f9-b200-dce012140422}"
version="1.0.0.0" helpdir="" resourceid="0" flags="HASDISKIMAGE" />

Thank you very much for your help
Patrick Wolf
www.patrickwolf.net



----------------------------------------------------------------------------------------------
Service.cs (in VS 2005 project)
----------------------------------------------------------------------------------------------
using System.Runtime.InteropServices;

using Microsoft.VisualBasic;

namespace Test.API.COM

{

// [ComVisible(true)]

[ComClass(Service.ClassId, Service.InterfaceId, Service.EventsId)]

public class Service

{

#region "COM GUIDs"

public const string ClassId = "D50636AF-44BF-4A4C-BF41-713070D9ECA2";

public const string InterfaceId = "FBA843CB-D290-4C95-8D04-C72B51A29F06";

public const string EventsId = "491518C7-D50F-4A36-A490-75A93C168E44";

#endregion

public Service():base() {}


public string GetMe(string test){return "return value: " + test;}

}

}

----------------------------------------------------------------------------------------------
AssemblyInfo.cs (in VS 2005 project)
----------------------------------------------------------------------------------------------
....
[assembly: ComVisible(true)]
[assembly: Guid("2af5c211-13bf-43f9-b200-dce012140422")]
....

----------------------------------------------------------------------------------------------
MsAccess VBA Code
----------------------------------------------------------------------------------------------
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim d As Test_API_COM.Service
Set d = New Test_API_COM.Service

MsgBox (d.GetMe("HIPAT"))

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox err.Description & err.LastDllError & err.Source & err.Number
Resume Exit_Command0_Click

End Sub

----------------------------------------------------------------------------------------------
MSACCESS.EXE.CONFIG
----------------------------------------------------------------------------------------------
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>

----------------------------------------------------------------------------------------------
MSACCESS.EXE.MANIFEST
----------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="10.0.4302.0" processorArchitecture="X86" name="MSACCESS.EXE"
type="win32"
/>

<file name="Cafe.Amanda.API.COM.dll"
xmlns="urn:schemas-microsoft-com:asm.v1">
<typelib
tlbid="{2af5c211-13bf-43f9-b200-dce012140422}"
version="1.0.0.0" helpdir="" resourceid="0" flags="HASDISKIMAGE" />
<comClass
clsid="{D50636AF-44BF-4A4C-BF41-713070D9ECA2}"
threadingModel="Apartment"
tlbid="{2af5c211-13bf-43f9-b200-dce012140422}"
progid="Cafe_Amanda_API_COM.Service"
name="Cafe_Amanda_API_COM.Service"/>
</file>
</assembly>
 
P

Patrick Wolf

Here is the error message from the event log:

Generate Activation Context failed for C:\Program Files\Microsoft
Office\OFFICE11\MSACCESS.EXE.Manifest. Reference error message: The
operation completed successfully.
Syntax error in manifest or policy file "C:\Program Files\Microsoft
Office\OFFICE11\MSACCESS.EXE.Manifest" on line 13.

Line 13 is the line containing this
I am still not sure what is wrong though?

------------------------------------------------------------------------------
When I embed this manifest into the dll
-------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="Test.API.COM"
version="1.0.0.0"
processorArchitecture="MSIL" />
<clrClass
clsid="{C4443F8E-D613-30A0-AF0A-CDDC748F7F32}"
progid="Test.API.COM.Service"
threadingModel="Both"
name="Test.API.COM.Service"
runtimeVersion="v2.0.50727">
</clrClass>
<file name="Test.API.COM.dll">
</file>
</assembly>
------------------------------------------------------------------------------
and change MSAccess.exe.manifest to
------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="MSACCESS.EXE"
version="11.0.6566.0"
language="neutral"
processorArchitecture="x86"
type="win32" />

<dependency>
<dependentAssembly>
<assemblyIdentity
name="Cafe.Amanda.API.COM"
version="1.0.0.0"
processorArchitecture="MSIL" />
</dependentAssembly>
</dependency>
</assembly>
------------------------------------------------------------------------------

It does work but now manifest and the Test.API.COM.dll both have to live in
the Office folder which is not a super solution.


Thanks a lot for any more tips
Patrick
 
P

Phil Wilson

Your original post has that tlbid in there twice - that doesn't look right.

AFAIK, the reg-free COM manifest info is associated with an exe, not a Dll.

I've used this on an exe (I've changed guids and progids):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">


<file name="Some.dll">

<comClass description="whatever"
clsid="{7A1AD41F-CC49-11D3-86CB-000000000000}"
progid="x.y.1"
threadingModel = "apartment" />

<typelib tlbid="{C22F4541-83C9-11D2-8576-0010123452FD}"
version="2.0" helpdir=""/>

<comClass description="Collect info"
clsid="{C22F4550-83C9-11D2-8576-0654325082FD}"
progid="yy.yy.11"
threadingModel = "apartment" />

<comClass description="some info"
clsid="{C22F4552-83C9-11D2-8576-0017678982FD}"
progid="ww.xx/1"
threadingModel = "apartment" />

</file>


</assembly>


Phil Wilson
[MVP Windows Installer]

Patrick Wolf said:
Here is the error message from the event log:

Generate Activation Context failed for C:\Program Files\Microsoft
Office\OFFICE11\MSACCESS.EXE.Manifest. Reference error message: The
operation completed successfully.
Syntax error in manifest or policy file "C:\Program Files\Microsoft
Office\OFFICE11\MSACCESS.EXE.Manifest" on line 13.

Line 13 is the line containing this
I am still not sure what is wrong though?

------------------------------------------------------------------------------
When I embed this manifest into the dll
-------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="Test.API.COM"
version="1.0.0.0"
processorArchitecture="MSIL" />
<clrClass
clsid="{C4443F8E-D613-30A0-AF0A-CDDC748F7F32}"
progid="Test.API.COM.Service"
threadingModel="Both"
name="Test.API.COM.Service"
runtimeVersion="v2.0.50727">
</clrClass>
<file name="Test.API.COM.dll">
</file>
</assembly>
------------------------------------------------------------------------------
and change MSAccess.exe.manifest to
------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="MSACCESS.EXE"
version="11.0.6566.0"
language="neutral"
processorArchitecture="x86"
type="win32" />

<dependency>
<dependentAssembly>
<assemblyIdentity
name="Cafe.Amanda.API.COM"
version="1.0.0.0"
processorArchitecture="MSIL" />
</dependentAssembly>
</dependency>
</assembly>
------------------------------------------------------------------------------

It does work but now manifest and the Test.API.COM.dll both have to live
in the Office folder which is not a super solution.


Thanks a lot for any more tips
Patrick
 
Top