Hi,
I am trying to expose my .NET 2.0 class as a COM type using the following
attributes for the attributes
[ClassInterface( ClassInterfaceT ype.None)]
[Guid("8D0240AD-1BBE-4831-8214-39DD46A4A797")]
I have the "Register for COM Interop" build property set to true. I also
have two functions in the class to register and unregister the COM with the
registry. But when i try to build it in VS.NET 2005, i get the following
error "XXX.dll does not contain any types that can be registered for COM
Interop" and "XXX.dll does not contain any types that can be Unregistered for
COM Interop". The same code works perfectly in VS.NET 2003. Anybody know of
any reasons why this is happeneing or what i am doing wrong?
Thank You,
Vish
Nov 17 '05
26 10679
Yeah I know it's always been default because it's bitten me in the
rear-end a few times ;-). I honestly didn't think that they would have
made a breaking change like that. So the question that still remains,
did setting [ComVisible(true )] really solve the problem or was it
something else?
Jason Newell
Willy Denoyette [MVP] wrote: "Jason Newell" <no****@nospam. com> wrote in message news:Oe******** ******@TK2MSFTN GP15.phx.gbl...
Vish,
Willy is correct per documentation: http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx.
I'd be interested to know why explicitly settings [ComVisible(true )] fixed the problem. Unfortunately, I don't have 2.0 or I'd test it myself.
Jason Newell
And not only per documentation ;-), it was the default since version 1.0 and did not change in v2.0 (that would be a breaking change). I tested this with v2.0 and I can confirm 'true' is still the default.
Willy.
"Jason Newell" <no****@nospam. com> wrote in message
news:eC******** ******@TK2MSFTN GP11.phx.gbl... Yeah I know it's always been default because it's bitten me in the rear-end a few times ;-). I honestly didn't think that they would have made a breaking change like that. So the question that still remains, did setting [ComVisible(true )] really solve the problem or was it something else?
Jason Newell
Pretty sure it was something else (my guess: missing public on the class).
Willy.
Hi,
Ok. I am not sure why but it did fix the issue. Obviously y'all know more on
this subject than i do. But i am posting my code below if y'all are still
interested.
[ClassInterface( ClassInterfaceT ype.None)]
[Guid("8D0240AD-1BBE-4831-8214-39DD46A4A797")]
[ComVisible(true )]
public sealed class TestTool : BaseCommand
{
private IApplication m_app;
public override void OnCreate(object hook)
{
if (hook != null)
{
if (hook is IMxApplication)
{
m_app = (IApplication)h ook;
}
}
}
public override void OnClick()
{
IMxDocument mxDoc = (IMxDocument)m_ app.Document;
IActiveView activeView = mxDoc.ActiveVie w;
activeView.Exte nt = activeView.Full Extent;
activeView.Refr esh();
}
public TestTool()
{
base.m_category = "Vish's Test";
base.m_caption = "Full Extent C#";
base.m_message = "Zooms the display to its full extent";
base.m_toolTip = "Full Extent C#";
base.m_name = "Developer Samples_FullExt ent C#";
string[] res = GetType().Assem bly.GetManifest ResourceNames() ;
if (res.GetLength( 0) > 0)
{
base.m_bitmap = new
System.Drawing. Bitmap(GetType( ).Assembly.GetM anifestResource Stream(res[0]));
}
}
#region Component Category Registration
[ComRegisterFunc tion()]
[ComVisible(fals e)]
static void RegisterFunctio n(String regKey)
{
MxCommands.Regi ster(regKey);
}
[ComUnregisterFu nction()]
[ComVisible(fals e)]
static void UnregisterFunct ion(String regKey)
{
MxCommands.Unre gister(regKey);
}
#endregion
}
"Willy Denoyette [MVP]" wrote: "Jason Newell" <no****@nospam. com> wrote in message news:eC******** ******@TK2MSFTN GP11.phx.gbl... Yeah I know it's always been default because it's bitten me in the rear-end a few times ;-). I honestly didn't think that they would have made a breaking change like that. So the question that still remains, did setting [ComVisible(true )] really solve the problem or was it something else?
Jason Newell
Pretty sure it was something else (my guess: missing public on the class).
Willy.
Sorry, but this is not a complete sample (missing BaseCommand), so there is
lttle I can do with it, but trust me [ComVisible(true )] IS the default.
I'm also not entirely clear on the purpose is of this class for a COM
client, true, this object creatable from COM clients, but none of it's
methods are callable.
Willy.
"Vish" <Vi**@discussio ns.microsoft.co m> wrote in message
news:EB******** *************** ***********@mic rosoft.com... Hi,
Ok. I am not sure why but it did fix the issue. Obviously y'all know more on this subject than i do. But i am posting my code below if y'all are still interested.
[ClassInterface( ClassInterfaceT ype.None)] [Guid("8D0240AD-1BBE-4831-8214-39DD46A4A797")] [ComVisible(true )] public sealed class TestTool : BaseCommand { private IApplication m_app;
public override void OnCreate(object hook) { if (hook != null) { if (hook is IMxApplication) { m_app = (IApplication)h ook; } } }
public override void OnClick() { IMxDocument mxDoc = (IMxDocument)m_ app.Document; IActiveView activeView = mxDoc.ActiveVie w; activeView.Exte nt = activeView.Full Extent; activeView.Refr esh(); }
public TestTool() { base.m_category = "Vish's Test"; base.m_caption = "Full Extent C#"; base.m_message = "Zooms the display to its full extent"; base.m_toolTip = "Full Extent C#"; base.m_name = "Developer Samples_FullExt ent C#";
string[] res = GetType().Assem bly.GetManifest ResourceNames() ; if (res.GetLength( 0) > 0) { base.m_bitmap = new System.Drawing. Bitmap(GetType( ).Assembly.GetM anifestResource Stream(res[0])); } }
#region Component Category Registration
[ComRegisterFunc tion()] [ComVisible(fals e)] static void RegisterFunctio n(String regKey) { MxCommands.Regi ster(regKey); }
[ComUnregisterFu nction()] [ComVisible(fals e)] static void UnregisterFunct ion(String regKey) { MxCommands.Unre gister(regKey); }
#endregion }
"Willy Denoyette [MVP]" wrote:
"Jason Newell" <no****@nospam. com> wrote in message news:eC******** ******@TK2MSFTN GP11.phx.gbl... > Yeah I know it's always been default because it's bitten me in the > rear-end a few times ;-). I honestly didn't think that they would have > made a breaking change like that. So the question that still remains, > did > setting [ComVisible(true )] really solve the problem or was it something > else? > > > Jason Newell > >
Pretty sure it was something else (my guess: missing public on the class).
Willy.
Hi Willy,
I wrote this class as an added tool for ESRI's ArcMap Software. The
BaseCommand class is part of their ArcObjects pacakage. So i will not be
provide you with that class. Anyway the the functions of the class below was
called and successfully executed from ArcMap which is completely built on
COM. Anyway that is not to say that you are write about what you are saying.
I just maybe it will help m eunderstand whats happeneing better. I class
below successfully created a new toolbar button and executed on click. Please
let me know what you think.
-Vish
"Willy Denoyette [MVP]" wrote: Sorry, but this is not a complete sample (missing BaseCommand), so there is lttle I can do with it, but trust me [ComVisible(true )] IS the default.
I'm also not entirely clear on the purpose is of this class for a COM client, true, this object creatable from COM clients, but none of it's methods are callable.
Willy.
"Vish" <Vi**@discussio ns.microsoft.co m> wrote in message news:EB******** *************** ***********@mic rosoft.com... Hi,
Ok. I am not sure why but it did fix the issue. Obviously y'all know more on this subject than i do. But i am posting my code below if y'all are still interested.
[ClassInterface( ClassInterfaceT ype.None)] [Guid("8D0240AD-1BBE-4831-8214-39DD46A4A797")] [ComVisible(true )] public sealed class TestTool : BaseCommand { private IApplication m_app;
public override void OnCreate(object hook) { if (hook != null) { if (hook is IMxApplication) { m_app = (IApplication)h ook; } } }
public override void OnClick() { IMxDocument mxDoc = (IMxDocument)m_ app.Document; IActiveView activeView = mxDoc.ActiveVie w; activeView.Exte nt = activeView.Full Extent; activeView.Refr esh(); }
public TestTool() { base.m_category = "Vish's Test"; base.m_caption = "Full Extent C#"; base.m_message = "Zooms the display to its full extent"; base.m_toolTip = "Full Extent C#"; base.m_name = "Developer Samples_FullExt ent C#";
string[] res = GetType().Assem bly.GetManifest ResourceNames() ; if (res.GetLength( 0) > 0) { base.m_bitmap = new System.Drawing. Bitmap(GetType( ).Assembly.GetM anifestResource Stream(res[0])); } }
#region Component Category Registration
[ComRegisterFunc tion()] [ComVisible(fals e)] static void RegisterFunctio n(String regKey) { MxCommands.Regi ster(regKey); }
[ComUnregisterFu nction()] [ComVisible(fals e)] static void UnregisterFunct ion(String regKey) { MxCommands.Unre gister(regKey); }
#endregion }
"Willy Denoyette [MVP]" wrote:
"Jason Newell" <no****@nospam. com> wrote in message news:eC******** ******@TK2MSFTN GP11.phx.gbl... > Yeah I know it's always been default because it's bitten me in the > rear-end a few times ;-). I honestly didn't think that they would have > made a breaking change like that. So the question that still remains, > did > setting [ComVisible(true )] really solve the problem or was it something > else? > > > Jason Newell > >
Pretty sure it was something else (my guess: missing public on the class).
Willy.
Hi,
I have the same problem. If I put [ComVisible(true )] on my class and
methods, it compiles, but I can't use the methods.
As an experiment I created a default Class Library, checked the
"Register for COM interop" -button, and I got the same error message:
"Com_test.d ll" does not contain any types that can be registered for
COM Interop.
/Erik
"Erik" <er************ *@bredband.net> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com... Hi,
I have the same problem. If I put [ComVisible(true )] on my class and methods, it compiles, but I can't use the methods.
As an experiment I created a default Class Library, checked the "Register for COM interop" -button, and I got the same error message: "Com_test.d ll" does not contain any types that can be registered for COM Interop.
/Erik
Please post your class. Note that this has nothing to do with the ComVisible
attribute (which is definately true by default).
Willy.
In my experiment i created an empty class library, resulting in the
following code.
using System;
using System.Collecti ons.Generic;
using System.Text;
namespace Com_test
{
public class Class1
{
}
}
Shouldn't it compile without an error, even with "Register for COM
interop" checked?
"Erik" <er************ *@bredband.net> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.com... In my experiment i created an empty class library, resulting in the following code.
using System; using System.Collecti ons.Generic; using System.Text;
namespace Com_test { public class Class1 { } }
Shouldn't it compile without an error, even with "Register for COM interop" checked?
This class will compile but cannot be registered for COM interop as it
doesn't have an explicit public empty constructor .
this ...
public class Class1
{
public Class1(){}
}
will do.
Willy.
Hi Willy,
Since the class i had created did have a constructor explicitly defined, why
do you think i wasn't able to compile my class in 2.0
Thank You,
Vish
"Willy Denoyette [MVP]" wrote: "Erik" <er************ *@bredband.net> wrote in message news:11******** *************@g 47g2000cwa.goog legroups.com... In my experiment i created an empty class library, resulting in the following code.
using System; using System.Collecti ons.Generic; using System.Text;
namespace Com_test { public class Class1 { } }
Shouldn't it compile without an error, even with "Register for COM interop" checked?
This class will compile but cannot be registered for COM interop as it doesn't have an explicit public empty constructor .
this ... public class Class1 { public Class1(){} }
will do.
Willy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: roy |
last post by:
I try to call com written in VB 6.0. When I use VS.net
Studio to do the debuging, some time it works fine, some
time I got the following message:
Server Error in '/GISOnlineReservation' Application.
-----------------------------------------------------------
---------------------
Configuration Error
Description: An error occurred during the processing of a
|
by: roy |
last post by:
I try to call com written in VB 6.0., some time it works
fine, some time I got the following message:
Server Error in '/GISOnlineReservation' Application.
-----------------------------------------------------------
---------------------
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request.
|
by: keefah |
last post by:
Hi,
I'm writing a C# web app that uses Outlook to send email. I use a reference
to the Microsoft Outlook 11.0 Object Library, but it's giving me problems. I
tracked down some stuff on the Net about the global assembly cache (GAC) and
primary interop assemblies (PIA) and so forth, and did all the
recommendations, in terms of tweeking Office, installing the .NET Office
stuff for framework 1.1, etc. I got it to the point where it compiles ok,...
|
by: lacour |
last post by:
I can't seem to figure out the difference between adding a COM dll
reference in VS2003 and by using TLBIMP.
I have a COM dll that references another COM dll, and I want the syntax
of my interop-filenames to be interop.<NameOfCOMDLL>.dll
I now make the first interop file
tlbimp COM1.dll /out:interop.COM1.dll /namespace:COM1
|
by: Nadav |
last post by:
Hi,
Introduction
***************
I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer, this layer manage the underlying COM Objects and upon request, provide a pointer to those objects to the 'API Consumer', following is an illustration of the system:
API Consumer ( Native C++/C# )
||
*******************************************
* ...
| |
by: Rob Edwards |
last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message:
"A reference to 'Microsoft CDO for Exchange Management Library' could not be added. Converting the type library to a .Net assembly failed. A depended type library 'CDO' could not be converted to a .NET assembly. A dependent type library 'ADODB' could not be converted to a .NET assembly. Item has already been added."
...
|
by: R Reyes |
last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly
to work in my VS2005 project? I'm trying to manipulate MS Word from my Web
Form application and I can't get passed this screen below. Please help,
thanks in advance...
Configuration Error
Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify...
|
by: JC |
last post by:
Anybody knows what problem has this code? I think, in the Garbage
Collector? You know the Solution?
The program in the test's case, whit 350 contacts, run OK before number
86. The error is a "Array index out of bounds".
Microsoft.Office.Interop.Outlook._Application olApp = new
Microsoft.Office.Interop.Outlook.ApplicationClass();
Microsoft.Office.Interop.Outlook._NameSpace olNs =
olApp.GetNamespace("MAPI");
|
by: allbelonging |
last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook
Problem:
I have my outlook 2003 configured with multiple mailbox on my local machine.
I want to specify the mailbox and server (Exchange server mail box)
to connect and then save the mailitems(from Inbox or any other folder)
based on a filter to a*.msg file.
I want to achieve this using only one Interop dll if this is possible.
Tried so far:
|
by: Tina |
last post by:
I've gotten this before where it says there is a problem with Interop.MSDASC
but I can't remember what causes this. This is a 1.1 app I'm trying to
debug in vs2005. It was running yesterday just fine.
Help!
T
Server Error in '/VT.Users' Application.
--------------------------------------------------------------------------------
Configuration Error
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |