473,320 Members | 1,572 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.

TypeForwardedToApp attribute.

Hi,

TypeForwardedToApp is one of the attributes covered in the MS upgrade
exam 70-553 http://www.microsoft.com/learning/exams/70-553.asp.

I've tried to code a short example in vb.net to test my understanding
of the attribute.
Unfortunetely, I could not get the attribute to work in vb.net (program
throws a TypeLoadException).
What's strange is that the c# examples using the same driver do work.

I wonder if anyone here has managed to get the TypeForwardedToApp
attribute to work in vb.net? Or perhaps knows what I'm doing wrong in
the vb.net examples.

Regards,
Andy

---
Module1.vb
---
Imports MyNamespace
'The test driver
Namespace TypeForwardedTo
Module Module1

Sub Main()
Dim c As New Class1
End Sub

End Module
End Namespace

---
Class1.vb in ClassLibrary1VB assembly
---
<Assembly:
System.Runtime.CompilerServices.TypeForwardedTo(Ge tType(MyNamespace.Class1))>

Namespace MyNamespace
'In ClassLibrary1VB assembly
'Public Class Class1
' Public Sub New()
' Console.WriteLine("In ClassLibrary1VB assembly")
' End Sub
'End Class
End Namespace

---
Class1.vb in ClassLibrary2VB assembly
---
Namespace MyNamespace
Public Class Class1
Public Sub New()
Console.WriteLine("In ClassLibrary2VB assembly")
End Sub
End Class
End Namespace

---
Class1.cs in ClassLibrary1CS assembly
---
[assembly:
System.Runtime.CompilerServices.TypeForwardedTo(ty peof(MyNamespace.Class1))
]
//using System;
//using System.Collections.Generic;
//using System.Text;

namespace MyNamespace
{
//public class Class1
//{
// public Class1()
// {
// Console.WriteLine("In the ClassLibrary1CS assembly");
// }

//}
}

---
Class1.cs in ClassLibrary2CS assembly
---
using System;
using System.Collections.Generic;
using System.Text;

namespace MyNamespace
{
public class Class1
{
public Class1()
{
Console.WriteLine("In the ClassLibrary2CS assembly");
}

}
}

Jul 12 '06 #1
2 979
Andy,

Make sure that the root namespace of the projects are either equal or
cleared. Otherwise you'll have two different types
"ClassLibrary1VB.MyNamespace.Class1" and
"ClassLibrary2VB.MyNamespace.Class1". The full type name must be the
same for the attribute to work.

Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 12 '06 #2
Thanks Mattias,

Unfortunately, clearing both VB class library root namespace and
setting both root namespaces equally still raises that particular
exception.

At least the c# examples work, so I know what the
TypeForwardedToAppAttribute is supposed to do and where it might be
useful. I'm just a bit disappointed because I mainly work using vb.net.

Regards,
Andy

Jul 12 '06 #3

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

Similar topics

1
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
4
by: Lénaïc Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I've some namespace problems when defining default values for attributes. My problem seems to come from the fact that the attributes are...
2
by: gary.goodwin | last post by:
HI I am trying to understand Attribute usage. For example the class SerializableAttribute is a class correct? So why when it is actually u sed the "Attribute" portion of the name is dropped. The...
18
by: Gabriel Rossetti | last post by:
Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
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...
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...
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
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.