What is an Ignore list?
Creating COM components in C#
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Ñîîáùåñòâà
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > .Net Development > Creating COM components in C# 13 May 2004 17:32:08

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Ìîäåðàòîð:

Creating COM components in C#

Paul Grenyer 12 May 2004 16:46:27
 *** Before acting on this e-mail or opening any attachment you are advised to read the disclaimer at the end of this e-mail ***

Hi All

I want to create a C# dll that is available to COM aware clients. I've
followed the example in Inside C# (2nd Ed) and have the following:

using System;
using System.Windows.Form­s;
using System.Runtime.Inte­ropServices;

namespace CommsServer
{
[ClassInterface(ClassInterfaceType.None)]
public class UserDatagramProtoco­l
{
public UserDatagramProtoco­l()
{
}

public void Send( Byte[] message, string mcastGroup, string
port, string ttl, string rep )
{

}
}
}

in a ClassLibrary dll. I have then generated the type library:

"C:\WINNT\Microsoft­.NET\Framework\v1.1.­4322\regasm" CommsServer.dll
/tlb:/CommsServer.t­lb

and created a C++ client:


#import "..\bin\debug\Comms­Server.tlb"
#include <iostream>


int main()
{

return EXIT_SUCCESS;
}

However, when I build the client I get the following errors:

error C2146: syntax error : missing ';' before identifier 'GetType'
error C2501: 'CommsServer::_User­DatagramProtocol::_T­ypePtr' : missing
storage-class or type specifiers
warning C4183: 'GetType': missing return type; assumed to be a member
function returning 'int'
error C2143: syntax error : missing ';' before
'CommsServer::_User­DatagramProtocol::Ge­tType'
error C2433: '_TypePtr' : 'inline' not permitted on data declarations
error C2501: '_TypePtr' : missing storage-class or type specifiers
error C2064: term does not evaluate to a function taking 2 arguments

I tried creating the object in VB6 as well, but that doesn't work either.

Regards
Paul


Paul Grenyer
Software Development Engineer
http://www.paulgren­yer.co.uk
--LongSig

communisis chorleys ltd
Computer Bureau
Manston Lane
Crossgates
Leeds
LS15 8AH

Telephone +44 (0)113 225 5306
Fax +44 (0)113 225 5914
Email Paul.Grenyer@commun­isis-dm.co.uk


*******************­********************­********************­***********
Please note: This e-mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy(s) of the communisis group in general.

Employees of the communisis group are required not to make any defamatory statements and not to infringe or authorise any infringement of copyright or any other legal right by e-mail. Any such communication is therefore outside the scope of employment of the individual concerned. The communisis group will not accept any liability in respect of such a communication.

Confidentiality: This e-mail and any attachments, together with their contents, are confidential unless otherwise explicitly stated in writing by the sender of this e-mail and are for the intended recipient only. If they have come to you in error you must not take any action in respect of them, which includes but is not limited to reproducing, sending or storing them, other than to notifying the sender immediately of the mistake, and deleting the e-mail, any attachments and any reproductions made by replying to it.

Viruses: This e-mail and any attachments have been scanned for viruses but we cannot guarantee that they are virus free. The recipient should check this e-mail and any attachments for viruses. The communisis group accepts no responsibility for any damage caused by any virus transmitted by this e-mail or any of its attachments. In the event of any unauthorised copying or forwarding, the recipient will be required to indemnify the communisis group against any claim for loss or damage caused by any viruses or otherwise.
*******************­********************­********************­***********


___________________­____________________­____________________­___________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagel­abs.com/email
___________________­____________________­____________________­___________

Add comment
Ivan Towlson 12 May 2004 17:21:55 permanent link ]
 As you are (rightly) suppressing the class interface, you need to supply
an explicit interface for COM to use. Thus, something like:

[assembly:ComVisible(true)]

[Guid(...)]
public interface ICommsServer { ... }

[ClassInterface(ClassInterfaceType.None)]
public class CommsServer : ICommsServer { ... }

I'm not sure if this is actually the cause of your problem, but it's
something I think you'll need to be aware of.

If adding the explicit interface doesn't help, it might be worth having
a look in the generated TLH and TLI files and see if anything you'd
expect to see (e.g. GUIDs, class/interface names, etc.) is obviously
missing.

Hope this helps,

--
Ivan Towlson
White Carbon


-----Original Message-----
From: Discussion relating to the specifics of the C# and Managed C++
languages [mailto:D­OTNET-CX@DISCUSS.DEVELOP.COM]On Behalf Of Paul
Grenyer
Sent: 12 May 2004 13:46
To: DOTNET-CX@DISCUSS.D­EVELOP.COM
Subject: [DOTNET-CX] Creating COM components in C#


I want to create a C# dll that is available to COM aware clients. I've
followed the example in Inside C# (2nd Ed) and have the following:

Add comment
Paul Grenyer 12 May 2004 17:44:28 permanent link ]
 *** Before acting on this e-mail or opening any attachment you are advised to read the disclaimer at the end of this e-mail ***

Hi Ivan

Thanks for the pointers. I now have:

using System;
using System.Windows.Form­s;
using System.Runtime.Inte­ropServices;

namespace CommsServer
{

[ComVisible(true)]
[Guid("1DB44778-857F-47d1-9D4A-D90F009EFF34")]
public interface IUserDatagramProtoc­ol
{
void Send( Byte[] message, string mcastGroup, string port,
string ttl, string rep );
}

[ClassInterface(ClassInterfaceType.None)]
public class UserDatagramProtoco­l : IUserDatagramProtoc­ol
{
public UserDatagramProtoco­l()
{
}

public void Send( Byte[] message, string mcastGroup, string
port, string ttl, string rep )
{

}
}
}

and a clien that now compiles and looks like this:

#import "..\bin\debug\Comms­Server.tlb"
#include <iostream>

int main()
{
CoInitialize(0);

try
{
CommsServer::IUserD­atagramProtocolPtr pComms( __uuidof(
CommsServer::UserDa­tagramProtocol ) );
}
catch( const _com_error& e )
{
std::cout << e.ErrorMessage() << std::endl;
}

CoUninitialize();

return EXIT_SUCCESS;
}

It gives me the error message "Class Not Registered". My tlh looks like
this:

// Created by Microsoft (R) C/C++ Compiler Version 13.10.3077 (2fb42baa).
//
// c:\temp\c#\commsser­ver\client\debug\com­msserver.tlh
//
// C++ source equivalent of Win32 type library ..\bin\debug\CommsS­erver.tlb
// compiler-generated file created 05/12/04 at 15:46:41 - DO NOT EDIT!

#pragma once
#pragma pack(push, 8)

#include <comdef.h>

namespace CommsServer {

//
// Forward references and typedefs
//

struct __declspec(uuid("1b­d8911d-6754-37d5-a3f­9-d6561c066ca9"))
/* LIBID */ __CommsServer;
struct __declspec(uuid("1d­b44778-857f-47d1-9d4­a-d90f009eff34"))
/* dual interface */ IUserDatagramProtoc­ol;
struct /* coclass */ UserDatagramProtoco­l;

//
// Smart pointer typedef declarations
//

_COM_SMARTPTR_TYPED­EF(IUserDatagramProt­ocol,
__uuidof(IUserDatag­ramProtocol));

//
// Type library items
//

struct __declspec(uuid("1d­b44778-857f-47d1-9d4­a-d90f009eff34"))
IUserDatagramProtoc­ol : IDispatch
{
//
// Wrapper methods for error-handling
//

HRESULT Send (
SAFEARRAY * message,
_bstr_t mcastGroup,
_bstr_t port,
_bstr_t ttl,
_bstr_t rep );

//
// Raw methods provided by interface
//

virtual HRESULT __stdcall raw_Send (
/*[in]*/ SAFEARRAY * message,
/*[in]*/ BSTR mcastGroup,
/*[in]*/ BSTR port,
/*[in]*/ BSTR ttl,
/*[in]*/ BSTR rep ) = 0;
};

struct __declspec(uuid("68­315b5e-742f-3b05-9ac­0-f4c53464676c"))
UserDatagramProtoco­l;
// interface _Object
// [ default ] interface IUserDatagramProtoc­ol

//
// Wrapper method implementations
//

#include "c:\temp\c#\commsse­rver\client\debug\co­mmsserver.tli"

} // namespace CommsServer

#pragma pack(pop)

Regards
Paul


Paul Grenyer
Software Development Engineer
http://www.paulgren­yer.co.uk
--LongSig

communisis chorleys ltd
Computer Bureau
Manston Lane
Crossgates
Leeds
LS15 8AH

Telephone +44 (0)113 225 5306
Fax +44 (0)113 225 5914
Email Paul.Grenyer@commun­isis-dm.co.uk

-----Original Message-----> From: Ivan Towlson [mailto:ivan.towlson@WHITE-CARBON.COM]> Sent: 12 May 2004 15:22> To: DOTNET-CX@DISCUSS.D­EVELOP.COM> Subject: Re: [DOTNET-CX] Creating COM components in C#>
As you are (rightly) suppressing the class interface, you> need to supply> an explicit interface for COM to use. Thus, something like:>
[assembly:ComVisible(true)]>
[Guid(...)]> public interface ICommsServer { ... }>
[ClassInterface(ClassInterfaceType.None)]> public class CommsServer : ICommsServer { ... }>
I'm not sure if this is actually the cause of your problem, but it's> something I think you'll need to be aware of.>
If adding the explicit interface doesn't help, it might be> worth having> a look in the generated TLH and TLI files and see if anything you'd> expect to see (e.g. GUIDs, class/interface names, etc.) is obviously> missing.>
Hope this helps,>
--> Ivan Towlson> White Carbon>
-----Original Message-----> From: Discussion relating to the specifics of the C# and Managed C++> languages [mailto:D­OTNET-CX@DISCUSS.DEVELOP.COM]On Behalf Of Paul> Grenyer> Sent: 12 May 2004 13:46> To: DOTNET-CX@DISCUSS.D­EVELOP.COM> Subject: [DOTNET-CX] Creating COM components in C#>
I want to create a C# dll that is available to COM aware clients. I've> followed the example in Inside C# (2nd Ed) and have the following:>
___________________­____________________­____________________­___________> This email has been scanned by the MessageLabs Email Security System.> For more information please visit http://www.messagel­abs.com/email> ___________________­____________________­____________________­___________>


*******************­********************­********************­***********
Please note: This e-mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy(s) of the communisis group in general.

Employees of the communisis group are required not to make any defamatory statements and not to infringe or authorise any infringement of copyright or any other legal right by e-mail. Any such communication is therefore outside the scope of employment of the individual concerned. The communisis group will not accept any liability in respect of such a communication.

Confidentiality: This e-mail and any attachments, together with their contents, are confidential unless otherwise explicitly stated in writing by the sender of this e-mail and are for the intended recipient only. If they have come to you in error you must not take any action in respect of them, which includes but is not limited to reproducing, sending or storing them, other than to notifying the sender immediately of the mistake, and deleting the e-mail, any attachments and any reproductions made by replying to it.

Viruses: This e-mail and any attachments have been scanned for viruses but we cannot guarantee that they are virus free. The recipient should check this e-mail and any attachments for viruses. The communisis group accepts no responsibility for any damage caused by any virus transmitted by this e-mail or any of its attachments. In the event of any unauthorised copying or forwarding, the recipient will be required to indemnify the communisis group against any claim for loss or damage caused by any viruses or otherwise.
*******************­********************­********************­***********


___________________­____________________­____________________­___________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagel­abs.com/email
___________________­____________________­____________________­___________

Add comment
Sean Chapman 12 May 2004 17:59:18 permanent link ]
 Ivan Towlson wrote:
Have a look in the registry to see if the CLSID mentioned in the TLH is>registered. If not, you may need to make the class ComVisible and>re-regasm.>
Another possible issue is whether COM can actually find your assembly.>Your .NET assembly needs to be either in your app (EXE) directory or the>GAC. (Even though your class is registered as a COM component, it's>*not* globally accessible a la COM unless you put it in the GAC. The>registered COM handler for all .NET classes is mscoree.dll, not the .NET>assembly itself.)>
-->Ivan Towlson>White Carbon>
-----Original Message----->From: Discussion relating to the specifics of the C# and Managed C++>languages [mailto:D­OTNET-CX@DISCUSS.DEVELOP.COM]On Behalf Of Paul>Grenyer>Sent: 12 May 2004 14:44>To: DOTNET-CX@DISCUSS.D­EVELOP.COM>Subject: Re: [DOTNET-CX] Creating COM components in C#>
namespace CommsServer>{> [ClassInterface(ClassInterfaceType.None)]> public class UserDatagramProtoco­l : IUserDatagramProtoc­ol> {> }>}>
It gives me the error message "Class Not Registered". My tlh looks like>this:>
dont know if it will help, but when i was using some COM stuff, I had to
use regsvcs.exe to register my dlls.

Add comment
Ivan Towlson 12 May 2004 18:03:26 permanent link ]
 Have a look in the registry to see if the CLSID mentioned in the TLH is
registered. If not, you may need to make the class ComVisible and
re-regasm.

Another possible issue is whether COM can actually find your assembly.
Your .NET assembly needs to be either in your app (EXE) directory or the
GAC. (Even though your class is registered as a COM component, it's
*not* globally accessible a la COM unless you put it in the GAC. The
registered COM handler for all .NET classes is mscoree.dll, not the .NET
assembly itself.)

--
Ivan Towlson
White Carbon


-----Original Message-----
From: Discussion relating to the specifics of the C# and Managed C++
languages [mailto:D­OTNET-CX@DISCUSS.DEVELOP.COM]On Behalf Of Paul
Grenyer
Sent: 12 May 2004 14:44
To: DOTNET-CX@DISCUSS.D­EVELOP.COM
Subject: Re: [DOTNET-CX] Creating COM components in C#


namespace CommsServer
{
[ClassInterface(ClassInterfaceType.None)]
public class UserDatagramProtoco­l : IUserDatagramProtoc­ol
{
}
}

It gives me the error message "Class Not Registered". My tlh looks like
this:

Add comment
Rocco Martin 12 May 2004 20:06:44 permanent link ]
 Make sure that you use the /codebase option when you use regasm. Your
COM components will not be able to see it otherwise.

Example:

regasm /codebase MyComInterop.dll

Cheers,
Rocco Martin
Corillian


-----Original Message-----
From: Discussion relating to the specifics of the C# and Managed C++
languages [mailto:D­OTNET-CX@DISCUSS.DEVELOP.COM] On Behalf Of Sean
Chapman
Sent: Wednesday, May 12, 2004 7:59 AM
To: DOTNET-CX@DISCUSS.D­EVELOP.COM
Subject: Re: [DOTNET-CX] Creating COM components in C#

Ivan Towlson wrote:
Have a look in the registry to see if the CLSID mentioned in the TLH is>registered. If not, you may need to make the class ComVisible and>re-regasm.>
Another possible issue is whether COM can actually find your assembly.>Your .NET assembly needs to be either in your app (EXE) directory or
GAC. (Even though your class is registered as a COM component, it's>*not* globally accessible a la COM unless you put it in the GAC. The>registered COM handler for all .NET classes is mscoree.dll, not the
.NET>assembly itself.)>
-->Ivan Towlson>White Carbon>
-----Original Message----->From: Discussion relating to the specifics of the C# and Managed C++>languages [mailto:D­OTNET-CX@DISCUSS.DEVELOP.COM]On Behalf Of Paul>Grenyer>Sent: 12 May 2004 14:44>To: DOTNET-CX@DISCUSS.D­EVELOP.COM>Subject: Re: [DOTNET-CX] Creating COM components in C#>
namespace CommsServer>{> [ClassInterface(ClassInterfaceType.None)]> public class UserDatagramProtoco­l : IUserDatagramProtoc­ol> {> }>}>
It gives me the error message "Class Not Registered". My tlh looks like>this:>
dont know if it will help, but when i was using some COM stuff, I had to
use regsvcs.exe to register my dlls.

Add comment
Paul Grenyer 13 May 2004 09:55:37 permanent link ]
 *** Before acting on this e-mail or opening any attachment you are advised to read the disclaimer at the end of this e-mail ***

Hi
Have a look in the registry to see if the CLSID mentioned in> the TLH is registered. If not, you may need to make the> class ComVisible and re-regasm.

There doesn't appear to be a CLSID in the tlh. All the GUIDs in the tlh are
in my registry:

CommsServer.UserDat­agramProtocol: {68315B5E-742F-3B05­-9AC0-F4C53464676C}
IUserDatagramProtoc­ol: {1DB44778-857F-47D1­-9D4A-D90F009EFF34}

{1DB44778-857F-47D1­-9D4A-D90F009EFF34}
TypeLib
Default: {1BD8911D-6754-37D5­-A3F9-D6561

I have also made the class ComVisible:

namespace CommsServer
{

[ComVisible(true)]
[Guid("1DB44778-857F-47d1-9D4A-D90F009EFF34")]
public interface IUserDatagramProtoc­ol
{
void Send( Byte[] message, string mcastGroup, string port,
string ttl, string rep );
}

[ComVisible(true)]
[Guid("144B64C7-DA04-45ba-A61F-C8954627ADAA")]
[ClassInterface(ClassInterfaceType.None)]
public class UserDatagramProtoco­l : IUserDatagramProtoc­ol
{

....

Rebuilt the DLL and then rebuilt the type library. Still "Class not
registered".
Another possible issue is whether COM can actually find your assembly.> Your .NET assembly needs to be either in your app (EXE)> directory or the> GAC. (Even though your class is registered as a COM component, it's> *not* globally accessible a la COM unless you put it in the GAC. The> registered COM handler for all .NET classes is mscoree.dll,> not the .NET> assembly itself.)

That was it! I needed to put the C# dll in the same directory as my client
executable. Thanks!

I now need to investigate the GAC as this component I am writing is for use
with SQL server.

Regards
Paul


Paul Grenyer
Software Development Engineer
http://www.paulgren­yer.co.uk
--LongSig

communisis chorleys ltd
Computer Bureau
Manston Lane
Crossgates
Leeds
LS15 8AH

Telephone +44 (0)113 225 5306
Fax +44 (0)113 225 5914
Email Paul.Grenyer@commun­isis-dm.co.uk


*******************­********************­********************­***********
Please note: This e-mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy(s) of the communisis group in general.

Employees of the communisis group are required not to make any defamatory statements and not to infringe or authorise any infringement of copyright or any other legal right by e-mail. Any such communication is therefore outside the scope of employment of the individual concerned. The communisis group will not accept any liability in respect of such a communication.

Confidentiality: This e-mail and any attachments, together with their contents, are confidential unless otherwise explicitly stated in writing by the sender of this e-mail and are for the intended recipient only. If they have come to you in error you must not take any action in respect of them, which includes but is not limited to reproducing, sending or storing them, other than to notifying the sender immediately of the mistake, and deleting the e-mail, any attachments and any reproductions made by replying to it.

Viruses: This e-mail and any attachments have been scanned for viruses but we cannot guarantee that they are virus free. The recipient should check this e-mail and any attachments for viruses. The communisis group accepts no responsibility for any damage caused by any virus transmitted by this e-mail or any of its attachments. In the event of any unauthorised copying or forwarding, the recipient will be required to indemnify the communisis group against any claim for loss or damage caused by any viruses or otherwise.
*******************­********************­********************­***********


___________________­____________________­____________________­___________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagel­abs.com/email
___________________­____________________­____________________­___________

Add comment
Paul Grenyer 13 May 2004 10:30:08 permanent link ]
 *** Before acting on this e-mail or opening any attachment you are advised to read the disclaimer at the end of this e-mail ***

All

It appears I have fallen at the next hurdle...

I have tried to register my c# dll in the Global Assembly Cash with
gacutil.exe. which gives me the following error message:

Failure adding assembly to the cache: Attempt to install an assembly without
a strong name

A quick investigation of MSDN and C# Programming by Jesse Liberty suggest
that I can give my c# dll a strong name using the sn tool:

sn -k CommsServer.key

Which gives:

Key pair written to CommsServer.key

and by adding the following to my assembly:

using System.Reflection;

[assembly: AssemblyKeyFile( "CommsServer.key")]
namespace CommsServer
{
...

However, this gives me the build error:

error CS0579: Duplicate 'AssemblyKeyFile' attribute

but I can't see where else I'm using it. :-s

Regards
Paul


Paul Grenyer
Software Development Engineer
http://www.paulgren­yer.co.uk
--LongSig

communisis chorleys ltd
Computer Bureau
Manston Lane
Crossgates
Leeds
LS15 8AH

Telephone +44 (0)113 225 5306
Fax +44 (0)113 225 5914
Email Paul.Grenyer@commun­isis-dm.co.uk



*******************­********************­********************­***********
Please note: This e-mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy(s) of the communisis group in general.

Employees of the communisis group are required not to make any defamatory statements and not to infringe or authorise any infringement of copyright or any other legal right by e-mail. Any such communication is therefore outside the scope of employment of the individual concerned. The communisis group will not accept any liability in respect of such a communication.

Confidentiality: This e-mail and any attachments, together with their contents, are confidential unless otherwise explicitly stated in writing by the sender of this e-mail and are for the intended recipient only. If they have come to you in error you must not take any action in respect of them, which includes but is not limited to reproducing, sending or storing them, other than to notifying the sender immediately of the mistake, and deleting the e-mail, any attachments and any reproductions made by replying to it.

Viruses: This e-mail and any attachments have been scanned for viruses but we cannot guarantee that they are virus free. The recipient should check this e-mail and any attachments for viruses. The communisis group accepts no responsibility for any damage caused by any virus transmitted by this e-mail or any of its attachments. In the event of any unauthorised copying or forwarding, the recipient will be required to indemnify the communisis group against any claim for loss or damage caused by any viruses or otherwise.
*******************­********************­********************­***********


___________________­____________________­____________________­___________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagel­abs.com/email
___________________­____________________­____________________­___________

Add comment
James Harvey 13 May 2004 10:34:12 permanent link ]
 Check out the AssemblyInfo.cs file for duplication. AssemblyInfo is where this should be stored.


-----Original Message-----
From: Paul Grenyer [mailto:P­aul.Grenyer@COMMUNISIS-DM.CO.UK]
Sent: 13 May 2004 08:30
To: DOTNET-CX@DISCUSS.D­EVELOP.COM
Subject: Re: [DOTNET-CX] Creating COM components in C#


*** Before acting on this e-mail or opening any attachment you are advised to read the disclaimer at the end of this e-mail ***

All

It appears I have fallen at the next hurdle...

I have tried to register my c# dll in the Global Assembly Cash with
gacutil.exe. which gives me the following error message:

Failure adding assembly to the cache: Attempt to install an assembly without
a strong name

A quick investigation of MSDN and C# Programming by Jesse Liberty suggest
that I can give my c# dll a strong name using the sn tool:

sn -k CommsServer.key

Which gives:

Key pair written to CommsServer.key

and by adding the following to my assembly:

using System.Reflection;

[assembly: AssemblyKeyFile( "CommsServer.key")]
namespace CommsServer
{
...

However, this gives me the build error:

error CS0579: Duplicate 'AssemblyKeyFile' attribute

but I can't see where else I'm using it. :-s

Regards
Paul


Paul Grenyer
Software Development Engineer
http://www.paulgren­yer.co.uk
--LongSig

communisis chorleys ltd
Computer Bureau
Manston Lane
Crossgates
Leeds
LS15 8AH

Telephone +44 (0)113 225 5306
Fax +44 (0)113 225 5914
Email Paul.Grenyer@commun­isis-dm.co.uk



*******************­********************­********************­***********
Please note: This e-mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy(s) of the communisis group in general.

Employees of the communisis group are required not to make any defamatory statements and not to infringe or authorise any infringement of copyright or any other legal right by e-mail. Any such communication is therefore outside the scope of employment of the individual concerned. The communisis group will not accept any liability in respect of such a communication.

Confidentiality: This e-mail and any attachments, together with their contents, are confidential unless otherwise explicitly stated in writing by the sender of this e-mail and are for the intended recipient only. If they have come to you in error you must not take any action in respect of them, which includes but is not limited to reproducing, sending or storing them, other than to notifying the sender immediately of the mistake, and deleting the e-mail, any attachments and any reproductions made by replying to it.

Viruses: This e-mail and any attachments have been scanned for viruses but we cannot guarantee that they are virus free. The recipient should check this e-mail and any attachments for viruses. The communisis group accepts no responsibility for any damage caused by any virus transmitted by this e-mail or any of its attachments. In the event of any unauthorised copying or forwarding, the recipient will be required to indemnify the communisis group against any claim for loss or damage caused by any viruses or otherwise.
*******************­********************­********************­***********


___________________­____________________­____________________­___________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagel­abs.com/email
___________________­____________________­____________________­___________


*******************­********************­********************­***********
This electronic mail message, including any attachments, is a
confidential communication exclusively between Babcock International
Group PLC or its subsidiary company and the intended recipient(s)
indicated as the addressee(s). It contains information which is private
and may be proprietary or covered by legal professional privilege. If
you receive this message in any form and you are not the intended
recipient you must not review, use, disclose or disseminate it.
We would be grateful if you could contact the sender upon receipt
and in any event you should destroy this message without delay.
Anything contained in this message that is not connected with the
business of Babcock International Group PLC is neither endorsed by
nor is the liability of this company.
Babcock International Group PLC
Telephone: +44(0)20 7291 5000
Fax: +44(0)20 7291 5055
Website: www.babcock.co.uk
*******************­********************­********************­***********

Add comment
Paul Stevens 13 May 2004 10:51:05 permanent link ]
 Check the assemblyinfo.cs file, tight at the bottom, it's always there

-----Original Message-----
From: Paul Grenyer [mailto:P­aul.Grenyer@COMMUNISIS-DM.CO.UK]
Sent: 13 May 2004 09:30 AM
To: DOTNET-CX@DISCUSS.D­EVELOP.COM
Subject: Re: [DOTNET-CX] Creating COM components in C#

*** Before acting on this e-mail or opening any attachment you are advised
to read the disclaimer at the end of this e-mail ***

All

It appears I have fallen at the next hurdle...

I have tried to register my c# dll in the Global Assembly Cash with
gacutil.exe. which gives me the following error message:

Failure adding assembly to the cache: Attempt to install an assembly without
a strong name

A quick investigation of MSDN and C# Programming by Jesse Liberty suggest
that I can give my c# dll a strong name using the sn tool:

sn -k CommsServer.key

Which gives:

Key pair written to CommsServer.key

and by adding the following to my assembly:

using System.Reflection;

[assembly: AssemblyKeyFile( "CommsServer.key")]
namespace CommsServer
{
...

However, this gives me the build error:

error CS0579: Duplicate 'AssemblyKeyFile' attribute

but I can't see where else I'm using it. :-s

Regards
Paul


Paul Grenyer
Software Development Engineer
http://www.paulgren­yer.co.uk
--LongSig

communisis chorleys ltd
Computer Bureau
Manston Lane
Crossgates
Leeds
LS15 8AH

Telephone +44 (0)113 225 5306
Fax +44 (0)113 225 5914
Email Paul.Grenyer@commun­isis-dm.co.uk



*******************­********************­********************­***********
Please note: This e-mail and its attachments contain only the opinions of
the sender and do not necessarily reflect the policy(s) of the communisis
group in general.

Employees of the communisis group are required not to make any defamatory
statements and not to infringe or authorise any infringement of copyright or
any other legal right by e-mail. Any such communication is therefore outside
the scope of employment of the individual concerned. The communisis group
will not accept any liability in respect of such a communication.

Confidentiality: This e-mail and any attachments, together with their
contents, are confidential unless otherwise explicitly stated in writing by
the sender of this e-mail and are for the intended recipient only. If they
have come to you in error you must not take any action in respect of them,
which includes but is not limited to reproducing, sending or storing them,
other than to notifying the sender immediately of the mistake, and deleting
the e-mail, any attachments and any reproductions made by replying to it.

Viruses: This e-mail and any attachments have been scanned for viruses but
we cannot guarantee that they are virus free. The recipient should check
this e-mail and any attachments for viruses. The communisis group accepts no
responsibility for any damage caused by any virus transmitted by this e-mail
or any of its attachments. In the event of any unauthorised copying or
forwarding, the recipient will be required to indemnify the communisis group
against any claim for loss or damage caused by any viruses or otherwise.
*******************­********************­********************­***********


___________________­____________________­____________________­___________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagel­abs.com/email
___________________­____________________­____________________­___________

*******************­********************­********************­********************­********************­********************­***
Everything in this e-mail and attachments relating to the official business of MultiChoice Africa is proprietary to
the company. Any view or opinion expressed in this message may be the view of the individual and should not automatically
be ascribed to the company. If you are not the intended recipient, you may not peruse, use, disseminate, distribute or
copy this message. If you have received this message in error, please notify the sender immediately by email, facsimile
or telephone and destroy the original message.
*******************­********************­********************­********************­********************­********************­***

Add comment
Paul Grenyer 13 May 2004 11:19:42 permanent link ]
 *** Before acting on this e-mail or opening any attachment you are advised to read the disclaimer at the end of this e-mail ***

Hi
Check out the AssemblyInfo.cs file for duplication.> AssemblyInfo is where this should be stored.

That was it! Thanks!

Regards
Paul


Paul Grenyer
Software Development Engineer
http://www.paulgren­yer.co.uk
--LongSig

communisis chorleys ltd
Computer Bureau
Manston Lane
Crossgates
Leeds
LS15 8AH

Telephone +44 (0)113 225 5306
Fax +44 (0)113 225 5914
Email Paul.Grenyer@commun­isis-dm.co.uk


*******************­********************­********************­***********
Please note: This e-mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy(s) of the communisis group in general.

Employees of the communisis group are required not to make any defamatory statements and not to infringe or authorise any infringement of copyright or any other legal right by e-mail. Any such communication is therefore outside the scope of employment of the individual concerned. The communisis group will not accept any liability in respect of such a communication.

Confidentiality: This e-mail and any attachments, together with their contents, are confidential unless otherwise explicitly stated in writing by the sender of this e-mail and are for the intended recipient only. If they have come to you in error you must not take any action in respect of them, which includes but is not limited to reproducing, sending or storing them, other than to notifying the sender immediately of the mistake, and deleting the e-mail, any attachments and any reproductions made by replying to it.

Viruses: This e-mail and any attachments have been scanned for viruses but we cannot guarantee that they are virus free. The recipient should check this e-mail and any attachments for viruses. The communisis group accepts no responsibility for any damage caused by any virus transmitted by this e-mail or any of its attachments. In the event of any unauthorised copying or forwarding, the recipient will be required to indemnify the communisis group against any claim for loss or damage caused by any viruses or otherwise.
*******************­********************­********************­***********


___________________­____________________­____________________­___________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagel­abs.com/email
___________________­____________________­____________________­___________

Add comment
Thomas Tomiczek 13 May 2004 14:36:23 permanent link ]
 Search for AssemblyKeyFile.

VS.NET has nice find mechanisms. Find in Files (run over the proejct)
may actually really be usefull here.

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)

-----Original Message-----> From: Discussion relating to the specifics of the C# and > Managed C++ languages [mailto:D­OTNET-CX@DISCUSS.DEVELOP.COM] > On Behalf Of Paul Grenyer> Sent: Donnerstag, 13. Mai 2004 09:30> To: DOTNET-CX@DISCUSS.D­EVELOP.COM> Subject: Re: [DOTNET-CX] Creating COM components in C#>
*** Before acting on this e-mail or opening any attachment > you are advised to read the disclaimer at the end of this e-mail ***>
It appears I have fallen at the next hurdle...>
I have tried to register my c# dll in the Global Assembly > Cash with gacutil.exe. which gives me the following error message:>
Failure adding assembly to the cache: Attempt to install an > assembly without a strong name>
A quick investigation of MSDN and C# Programming by Jesse > Liberty suggest that I can give my c# dll a strong name using > the sn tool:>
sn -k CommsServer.key>
Which gives:>
Key pair written to CommsServer.key>
and by adding the following to my assembly:>
using System.Reflection;>­
[assembly: AssemblyKeyFile( "CommsServer.key")] namespace > CommsServer {> ...>
However, this gives me the build error:>
error CS0579: Duplicate 'AssemblyKeyFile' attribute>
but I can't see where else I'm using it. :-s>
Regards> Paul>
Paul Grenyer> Software Development Engineer> http://www.paulgren­yer.co.uk> --LongSig>
communisis chorleys ltd> Computer Bureau> Manston Lane> Crossgates> Leeds> LS15 8AH>
Telephone +44 (0)113 225 5306> Fax +44 (0)113 225 5914> Email Paul.Grenyer@commun­isis-dm.co.uk>
*******************­********************­********************­***********> Please note: This e-mail and its attachments contain only the > opinions of the sender and do not necessarily reflect the > policy(s) of the communisis group in general.>
Employees of the communisis group are required not to make > any defamatory statements and not to infringe or authorise > any infringement of copyright or any other legal right by > e-mail. Any such communication is therefore outside the scope > of employment of the individual concerned. The communisis > group will not accept any liability in respect of such a > communication.>
Confidentiality: This e-mail and any attachments, together > with their contents, are confidential unless otherwise > explicitly stated in writing by the sender of this e-mail and > are for the intended recipient only. If they have come to you > in error you must not take any action in respect of them, > which includes but is not limited to reproducing, sending or > storing them, other than to notifying the sender immediately > of the mistake, and deleting the e-mail, any attachments and > any reproductions made by replying to it.>
Viruses: This e-mail and any attachments have been scanned > for viruses but we cannot guarantee that they are virus free. > The recipient should check this e-mail and any attachments > for viruses. The communisis group accepts no responsibility > for any damage caused by any virus transmitted by this e-mail > or any of its attachments. In the event of any unauthorised > copying or forwarding, the recipient will be required to > indemnify the communisis group against any claim for loss or > damage caused by any viruses or otherwise.> *******************­********************­********************­***********>
___________________­____________________­____________________­___________> This email has been scanned by the MessageLabs Email Security System.> For more information please visit > http://www.messagel­abs.com/email > ___________________­____________________­____________________­___________>

Add comment
Adam Sills 13 May 2004 17:30:18 permanent link ]
 
That was it! I needed to put the C# dll in the same directory> as my client> executable. Thanks!>
I now need to investigate the GAC as this component I am> writing is for use> with SQL server.

While the GAC is probably a better location for the assembly, realize that
you can use the /codebase option in regasm.exe to specify the location of
your assembly (thus eliminating the need for the GAC).

adam..

Add comment
Paul Grenyer 13 May 2004 17:32:08 permanent link ]
 *** Before acting on this e-mail or opening any attachment you are advised to read the disclaimer at the end of this e-mail ***

Hi
While the GAC is probably a better location for the assembly,> realize that> you can use the /codebase option in regasm.exe to specify the> location of> your assembly (thus eliminating the need for the GAC).

That sounds like a better solution. I'll try it, thanks!

Regards
Paul


Paul Grenyer
Software Development Engineer
http://www.paulgren­yer.co.uk
--LongSig

communisis chorleys ltd
Computer Bureau
Manston Lane
Crossgates
Leeds
LS15 8AH

Telephone +44 (0)113 225 5306
Fax +44 (0)113 225 5914
Email Paul.Grenyer@commun­isis-dm.co.uk


*******************­********************­********************­***********
Please note: This e-mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy(s) of the communisis group in general.

Employees of the communisis group are required not to make any defamatory statements and not to infringe or authorise any infringement of copyright or any other legal right by e-mail. Any such communication is therefore outside the scope of employment of the individual concerned. The communisis group will not accept any liability in respect of such a communication.

Confidentiality: This e-mail and any attachments, together with their contents, are confidential unless otherwise explicitly stated in writing by the sender of this e-mail and are for the intended recipient only. If they have come to you in error you must not take any action in respect of them, which includes but is not limited to reproducing, sending or storing them, other than to notifying the sender immediately of the mistake, and deleting the e-mail, any attachments and any reproductions made by replying to it.

Viruses: This e-mail and any attachments have been scanned for viruses but we cannot guarantee that they are virus free. The recipient should check this e-mail and any attachments for viruses. The communisis group accepts no responsibility for any damage caused by any virus transmitted by this e-mail or any of its attachments. In the event of any unauthorised copying or forwarding, the recipient will be required to indemnify the communisis group against any claim for loss or damage caused by any viruses or otherwise.
*******************­********************­********************­***********


___________________­____________________­____________________­___________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagel­abs.com/email
___________________­____________________­____________________­___________

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
respect your talk pals, avoid using obscene language, typing entire messages in CAPS, posting buy/sell ads or violating netiquette or the RF Criminal Code..


QAIX > .Net Development > Creating COM components in C# 13 May 2004 17:32:08

see also:
[JBoss Seam] - Re: Session scoped…
[JBossWS] - EJB3 webservice tutorial
[Security & JAAS/JBoss] - Security…
pass tests:
see also:
How to Rip DVD to iPod, MP4, AVI, WMV…
Palm vs. iPhone 3.0: which one woul...

  Copyright © 2001—2009 QAIX
Idea: Miñhael Monashev
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .