locked
Cannot declare assemby RRS feed

  • Question

  • 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?
    Tuesday, November 3, 2009 9:51 AM

All replies

  • Hi magmo,

    To use the types in the class library, we not only need to import the namespace, but also need to add referrence to the class library first. So I think the problem is caused by the reference of the class library isn't added to the WPF application.

    To get it work, you simply try the following steps:

    1. In the Solution Explorer, and select the referrence node of the WPF application.
    2. Right click "referrence" node, and select "Add".
    3. In the dialog, select "Project" tab, and select the class library you want to import.

    If you have any problems,  please feel free to let me know.

    Best regards,
    Bruce Zhou
    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.
    Wednesday, November 4, 2009 8:43 AM
  • No, it is added as a reference like you described, the thing is that I have to use the Imports part to get it to work.. here's what I have tried...

    In my assembly it look like this....

    Namespace MM.Cards.Pdf

        Public Class TestMe



    If I remove the Imports part I cannot access TestMe like this...

    Dim n As New Cards.Pdf.TestMe

    And I cannot access it like this....


    Dim n As New MM.Cards.Pdf.TestMe

    The only way I can access it is by using the Imports MM.Cards.Pdf

    and then declare it like this..

    Dim n As New TestMe



      
    Wednesday, November 4, 2009 9:29 AM
  • Hi magmo,

    I performed a test, and did not have the problem as you decribed. I can define "n" variable by using Dim n As New MM.Cards.Pdf.TestMe. If you like, I would share my test solution.

    But I don't know why you don't use the Import way which can save us lots of typing.

    Best regards,
    Bruce Zhou
    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.
    Wednesday, November 4, 2009 9:59 AM
  • Weird, I now created a new project and did just as have done in the other project, and the new project works just the way I want it. But I can still not do the same in the original project
    Wednesday, November 4, 2009 12:05 PM
  • Hi magmo,

    Then I am not sure with the reason. If you can send me a repro, then I will help to investigate the issue. My contact can be seen from my profile.

    Best regards,
    Bruce Zhou
    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.
    Wednesday, November 4, 2009 12:12 PM
  • Hi Bruce

    When I removed all unneccessary code in my project I discovered what caused the problem. In my project I have a wcf service reference, when I removed that one, I could declare the "n" varable as  I wanted to. But I don't really know why the wcf service interfered. Do you have any ideas?
    Wednesday, November 4, 2009 1:44 PM
  • The only thing the wcf and the class file had in common was that they both started with the same name like this..

    mm.mywcfservicename

    mm.myclassname

    I thought that as long as you have different name for all classes it is ok, but it appears that if they both start with xxx. this error occurs?

    Can you confirm this Bruce?


    Wednesday, November 4, 2009 3:12 PM