473,320 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Expose System.Uri to COM

Hi,

I have a Class in C# that exposes property from System.Uri type.
I want to access this property from classic Visual Basic.

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("C80CFADD-F676-4df6-8499-5C4F2E3434A5")]
public class TestClass
{
public TestClass()
{
}
public Uri MyUri
{
get
{
return new Uri("http://www.test.com");
}
}
}
Now I write in Visal Basic following code:

Dim oTestClass As New TestClass
If Not oTestClass.MyUri Is Nothing Then
'!!! I got "Type Mismatch" error here
'!!! I tried oTestClass.MyUri.ToString CStr(oTestClass.MyUri)
'!!! but result is that ToString is not exists and CStr also Type Mismatch
MsgBox oTestClass.MyUri
End If

Is there any way to do this?

Thanks,
Maxim.
Nov 16 '05 #1
2 1551
You would have to run TLBEXP on System.dll, and export that class.
However, I don't know that this is a good idea, since you would end up
exporting the whole library (and that's a pretty big library). Rather, you
should probably expose this property as a string, and then use that.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ma***@scp.co.il" <za*********@hotmail.com> wrote in message
news:79*************************@posting.google.co m...
Hi,

I have a Class in C# that exposes property from System.Uri type.
I want to access this property from classic Visual Basic.

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("C80CFADD-F676-4df6-8499-5C4F2E3434A5")]
public class TestClass
{
public TestClass()
{
}
public Uri MyUri
{
get
{
return new Uri("http://www.test.com");
}
}
}
Now I write in Visal Basic following code:

Dim oTestClass As New TestClass
If Not oTestClass.MyUri Is Nothing Then
'!!! I got "Type Mismatch" error here
'!!! I tried oTestClass.MyUri.ToString CStr(oTestClass.MyUri)
'!!! but result is that ToString is not exists and CStr also Type
Mismatch
MsgBox oTestClass.MyUri
End If

Is there any way to do this?

Thanks,
Maxim.

Nov 16 '05 #2
Hi Nicholas,

First of all thank you for fast reaction. I tried your suggestion, but
it did not help. I looked into the type library that TLBEXP exported from
System.dll, but surprised to know that there is no word about System.Uri.
I think that the problem is not connected to System.dll at all.
I mean if I for example expose property of System.Collections.ArrayList type
then I see it in classic Visual Basic and can work with it without TLBEXP of
no .NET dlls (for example I can see ArrayList.Count and it gives me a right
value). So in my opinion there is something special in System.Uri class.
If you will look into object browser, then you will see that it inheritted
from MarshalByRefObject. Please let me know if you have some idea?

Thank you again,
Maxim.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:<uy**************@TK2MSFTNGP12.phx.gbl>...
You would have to run TLBEXP on System.dll, and export that class.
However, I don't know that this is a good idea, since you would end up
exporting the whole library (and that's a pretty big library). Rather, you
should probably expose this property as a string, and then use that.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ma***@scp.co.il" <za*********@hotmail.com> wrote in message
news:79*************************@posting.google.co m...
Hi,

I have a Class in C# that exposes property from System.Uri type.
I want to access this property from classic Visual Basic.

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("C80CFADD-F676-4df6-8499-5C4F2E3434A5")]
public class TestClass
{
public TestClass()
{
}
public Uri MyUri
{
get
{
return new Uri("http://www.test.com");
}
}
}
Now I write in Visal Basic following code:

Dim oTestClass As New TestClass
If Not oTestClass.MyUri Is Nothing Then
'!!! I got "Type Mismatch" error here
'!!! I tried oTestClass.MyUri.ToString CStr(oTestClass.MyUri)
'!!! but result is that ToString is not exists and CStr also Type
Mismatch
MsgBox oTestClass.MyUri
End If

Is there any way to do this?

Thanks,
Maxim.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: rakefet | last post by:
Hi. I'm really new to this world of .Net so your help would be most appreciated... We have API and COM interfaces developed in c. We would also like to supply a .net interface to our clients....
7
by: MP | last post by:
Hello, I am trying to write a class that will expose some properties. One of the property is extracted from a SQL database and can be NULL or some integer value. Is there a elegant way of...
0
by: Kelly Johnson | last post by:
This is what I want to do: I want to create a UserControl that will hold a grid. This UserControl will be used specifically to display data about users, with that data appearing in the grid. ...
7
by: kids_pro | last post by:
I found FileInfo expose alot of methods & properties. However I can't get FileType from FileInfo I can only get File extension. How can I get fileType any build-in library allow me to do that?...
6
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like...
3
by: Miguel Ferreira via .NET 247 | last post by:
Hi ! I have developed a class Library with several classes and methods. Its working fine with a windows forms test application, but now i need to create a webservice that will expose those...
2
by: GoCoogs | last post by:
I'm trying to count how many items are in a dynamic collection. This is the code I have so far. *** Begin Code *** Public Class Rule Private _rulevars As RuleVarsCollection Private _rulename...
2
by: Luiz | last post by:
I'm constructing a class to database access using the following interface component : IDBDataAdapter my_i_DataAdapter; ...... The project has an instance of the class OdbcDataAdapter...
0
by: doron.grinstein | last post by:
A lot of architects tackle the issue of exposing internal web services and web applications to the Internet. How many times do you see a requirement such as "the application should be accessible to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
0
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.