.NET Framework Developer Center >
.NET Development Forums
>
.NET Base Class Library
>
cannot declare class directly
cannot declare class directly
- Hi
I have a wpf application and a classlibrary project together with it, I have set the namespace name in the properties of the classlibrary, I have also set the namespace name in the actual vb file (in the classlibrary). Then In my xaml.vb file I can Imports xxxx.nameofclasslibrary, but I cannot declare it direct like this...
Dim k As New name.of.my.classlibrary
I can't figure out why, what could be wrong?
Answers
- Hi JialiangI have just discovered what caused the problem, in my solution I had a wcf service reference, this service reference was named in this wayMM.ThenameOfmyservicereferenceAnd my class was named....MM.Cards.Pdf.TestMeSo beacuse they both started with MM. this error ocured. This is a little suprising to me, I thought that as long as the complete name is unique I will be fine, but obviously not.
- Marked As Answer byJialiang Ge [MSFT]MSFT, ModeratorFriday, November 13, 2009 6:22 AM
All Replies
- Hi magmo,
did you add areference to your class ?
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/ - In my class I have a public class called Testme, if I add this to my form...Imports myclass.blablabla.blablaThen I can access the TestMe Class by this line.Dim n As New TestMeBut if I remove the Imports part, I cannot do it like this...Dim n As New myclass.blablabla.blabla.TestMeShouldn't I supposed to be able to do that?
- Hi again
you need to call it:
Dim n As New blablabla.blabla.TestMe
without the myclass.
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/ - In my assembly it look like this....Namespace MM.Cards.PdfPublic Class TestMeIf I remove the Imports part I cannot access TestMe like this...Dim n As New Cards.Pdf.TestMeAnd I cannot access it like this....Dim n As New MM.Cards.Pdf.TestMeThe only way I can access it is by using the Imports MM.Cards.Pdfand then declare it like this..Dim n As New TestMe
- Hi again,
in pure VB.NET it works. So if you take a look inside the object browser and search for your class TestMe there you would see exactly where it is and then also how you can call it. I don`t know if this works in a wpf app.
If you have got questions about this, just ask.
Mark the thread as answered if the answer helps you. This helps others who have the same problem !
C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/ - I agree with Heslacher. Object Browser can tell you the "real" namespace of the class. You can also use .NET Reflector to see the namespace.
Also note that VB.NET projects have a root namespace defined in the project property. The namespaces that you specify in code are appended to the root namespace. You propably missed this one.
Regards,
Jialiang Ge
MSDN Subscriber Support in Forum
If you have any feedback of our support, please contact msdnmg@microsoft.com.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - Hello magmo
How are you? Do you have any progress in this issue? If you have any other questions, please feel free to post here.
Regards,
Jialiang Ge
MSDN Subscriber Support in Forum
If you have any feedback of our support, please contact msdnmg@microsoft.com.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - Hi JialiangI have just discovered what caused the problem, in my solution I had a wcf service reference, this service reference was named in this wayMM.ThenameOfmyservicereferenceAnd my class was named....MM.Cards.Pdf.TestMeSo beacuse they both started with MM. this error ocured. This is a little suprising to me, I thought that as long as the complete name is unique I will be fine, but obviously not.
- Marked As Answer byJialiang Ge [MSFT]MSFT, ModeratorFriday, November 13, 2009 6:22 AM
Hello
I'm glad that you have discovered the problem. You are allowed to use the class by specify its complete name (complete namespace + class name). If you just use the class name, the compiler is not able to decide which class to use under both namespace.
Regards,
Jialiang Ge
MSDN Subscriber Support in Forum
If you have any feedback of our support, please contact msdnmg@microsoft.com.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.


