Hi Folks,
I am coming up to speed with C# and I have run into an interesting
issue.
I have an old VB COM library that I need to access with a ProgId ==
'xyz'
I also have a C# class that is in a namespace like this:
"A.xyz.abc..."
I have added the COM library as a reference, but when I try to
reference out of the COM library, the compiler and Intellisense don't
see it:
xyz.objectname Temp = new xyz.objectname();
This fails, because it is looking in the namespace a.xyz for
objectname, not in the COM object.
Is there a way I can explicitly reference the object in the COM
library, or is there a way to alias the COM library?
Thanks!
Jami Bradley
reverse 2nd level domain: jb******@isa-og.com 8 1431
James,
You should be able to alias the namespace like this:
// Alias the A.xyz namespace.
using Axyz = A.xyz;
Then, you should be able to use:
// The class in A.xyz.
Axyz.abc pobj1 = new Axyz.abc;
// The com class.
xyz.objectname pobj2 = new xyz.objectname();
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"James Bradley" <jb******@isa-og.com> wrote in message
news:cg********************************@4ax.com... Hi Folks,
I am coming up to speed with C# and I have run into an interesting issue.
I have an old VB COM library that I need to access with a ProgId == 'xyz'
I also have a C# class that is in a namespace like this: "A.xyz.abc..."
I have added the COM library as a reference, but when I try to reference out of the COM library, the compiler and Intellisense don't see it:
xyz.objectname Temp = new xyz.objectname();
This fails, because it is looking in the namespace a.xyz for objectname, not in the COM object.
Is there a way I can explicitly reference the object in the COM library, or is there a way to alias the COM library?
Thanks!
Jami Bradley reverse 2nd level domain: jb******@isa-og.com
I saw that option in the using statement and thought that it would
work. Unfortunately, my problem is that I am *in* the namespace
A.xyz.abc, so I don't think I can alias my own namespace.
It looks something like this:
namespace A.xyz.abc
{
public class def
{
public void func()
{
// This statement attempts to access A.xyz.objectname:
xyz.objectname pobj2 = new xyz.objectname();
}
}
}
On Tue, 9 Dec 2003 13:15:49 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote: James,
You should be able to alias the namespace like this:
// Alias the A.xyz namespace. using Axyz = A.xyz;
Then, you should be able to use:
// The class in A.xyz. Axyz.abc pobj1 = new Axyz.abc;
// The com class. xyz.objectname pobj2 = new xyz.objectname();
Hope this helps.
James,
You can try to alias each object that you want to use, but I can see how
this could be unwieldy. Also, you could create the interop assembly
yourself using the TLBIMP program and then use the /namespace option to
indicate a different namespace which doesn't conflict.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"James Bradley" <jb******@isa-og.com> wrote in message
news:ag********************************@4ax.com... I saw that option in the using statement and thought that it would work. Unfortunately, my problem is that I am *in* the namespace A.xyz.abc, so I don't think I can alias my own namespace.
It looks something like this:
namespace A.xyz.abc { public class def { public void func() { // This statement attempts to access A.xyz.objectname: xyz.objectname pobj2 = new xyz.objectname(); } } }
On Tue, 9 Dec 2003 13:15:49 -0500, "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote:
James,
You should be able to alias the namespace like this:
// Alias the A.xyz namespace. using Axyz = A.xyz;
Then, you should be able to use:
// The class in A.xyz. Axyz.abc pobj1 = new Axyz.abc;
// The com class. xyz.objectname pobj2 = new xyz.objectname();
Hope this helps.
Thanks! I'll look into tlbimp and those options - I haven't done that
process manually with vs.net yet :-)
Is it possible to alias a COM object? For example, if I have
xyz.object1 in my COM library, can I use some alias to access that? I
thought the aliasing was only for the namespaces. I only have 3 or 4
objects like this, so individual aliasing is not all that bad.
Jami
On Tue, 9 Dec 2003 13:40:17 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote: James,
You can try to alias each object that you want to use, but I can see how this could be unwieldy. Also, you could create the interop assembly yourself using the TLBIMP program and then use the /namespace option to indicate a different namespace which doesn't conflict.
James,
Yes, you can alias individual types, like so:
// Alias the xyz.object type.
using MyComObject = xyz.object;
This will alias the one type with MyComObject. It ^should^ work, but
being in the namespace, I think you will still have problems (call it a
hunch). However, it wouldn't be so hard to try.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"James Bradley" <jb******@isa-og.com> wrote in message
news:p1********************************@4ax.com... Thanks! I'll look into tlbimp and those options - I haven't done that process manually with vs.net yet :-)
Is it possible to alias a COM object? For example, if I have xyz.object1 in my COM library, can I use some alias to access that? I thought the aliasing was only for the namespaces. I only have 3 or 4 objects like this, so individual aliasing is not all that bad.
Jami
On Tue, 9 Dec 2003 13:40:17 -0500, "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote:
James,
You can try to alias each object that you want to use, but I can see
howthis could be unwieldy. Also, you could create the interop assembly yourself using the TLBIMP program and then use the /namespace option to indicate a different namespace which doesn't conflict.
I tried aliasing the COM object and it worked great! Because the
using is outside of the namespace declaration, it had no trouble
finidng the COM object.
Here is what I ended up using:
using MyComLibrary = xyz;
and now I can access it directly:
MyComLibrary.object pObj = new MyComLibrary.object();
Thank you for all your help!
Jami
On Tue, 9 Dec 2003 13:55:47 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote: James,
Yes, you can alias individual types, like so:
// Alias the xyz.object type. using MyComObject = xyz.object;
This will alias the one type with MyComObject. It ^should^ work, but being in the namespace, I think you will still have problems (call it a hunch). However, it wouldn't be so hard to try.
James,
In addition to Nicholas's suggestions:
Have you tried to create an alias for the COM namespace before you enter the
A namespace?
using xyzcom = xyz namespace A.xyz.abc {
xyzcom.objectname pobj2 = new xyzcom.objectname();
Hope this helps
Jay
"James Bradley" <jb******@isa-og.com> wrote in message
news:ag********************************@4ax.com... I saw that option in the using statement and thought that it would work. Unfortunately, my problem is that I am *in* the namespace A.xyz.abc, so I don't think I can alias my own namespace.
It looks something like this:
namespace A.xyz.abc { public class def { public void func() { // This statement attempts to access A.xyz.objectname: xyz.objectname pobj2 = new xyz.objectname(); } } }
On Tue, 9 Dec 2003 13:15:49 -0500, "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote:
James,
You should be able to alias the namespace like this:
// Alias the A.xyz namespace. using Axyz = A.xyz;
Then, you should be able to use:
// The class in A.xyz. Axyz.abc pobj1 = new Axyz.abc;
// The com class. xyz.objectname pobj2 = new xyz.objectname();
Hope this helps.
I tried aliasing the COM object and it worked great! Because the
using is outside of the namespace declaration, it had no trouble
finidng the COM object.
Here is what I ended up using:
using MyComLibrary = xyz;
and now I can access it directly:
MyComLibrary.object pObj = new MyComLibrary.object();
Thank you for all your help!
Jami
On Tue, 9 Dec 2003 13:55:47 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote: James,
Yes, you can alias individual types, like so:
// Alias the xyz.object type. using MyComObject = xyz.object;
This will alias the one type with MyComObject. It ^should^ work, but being in the namespace, I think you will still have problems (call it a hunch). However, it wouldn't be so hard to try. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Wayne |
last post by:
I have the following Namesapces (only for example, would not name them this
way in production code)
Wayne.Test.Data
Wayne.Test.BR
With in Wayne.Test.Data name space I have the following...
|
by: yuliy |
last post by:
Hello gurus,
I stuck in following: how can I do forward declaration if the forward
declared class is in some namespace?
something like
// header
class std::string; // approach#1
|
by: alex sparsky |
last post by:
I have a rather unique problem that I need some advice on.
I have multiple c# controls that need to make use of a common
namespace. So when I go to include both controls that make use of
that...
|
by: Jéjé |
last post by:
Hi,
I'm using the ADOMD.Net 9 in my web site + a third party web control which
used the ADOMD.Net 8.0.
Everytime I compile my web site in VS 2005, a referecne to the 8.0 library
is added this...
|
by: bgeneto |
last post by:
I know that it's a very basic question, but I can't figure out or find
an answer to why do we have to specify a namespace, like this
#include<string>
using namespace std;
when using the...
|
by: Pep |
last post by:
Is it best to include the code "using namespace std;" in the source or
should each keyword in the std namespace be qualified by the namespace tag,
such as
std::cout << "using std namespace" <<...
|
by: Frederick Gotham |
last post by:
Back in the day, if you wanted a function to be self-contained within a
translation unit, you defined the function as "static".
If there were an external linkage function by the same name...
|
by: CrazyJohn |
last post by:
Hi guys,
This is my first time posting question here, if I break any rules,
please kindly point out. And I'm really glad to be a part of this
community.
Here is my question,
Our lecturer...
|
by: Andrew |
last post by:
I am having an interesting namespace conflict. When we use a third party
lib we create a company assembly for any descending classes to go in. I
have simplified the problem into the example...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |