Results 1 to 11 of 11

Thread: How do you remove dependencies.

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2011
    Location
    Melbourne
    Posts
    37

    How do you remove dependencies.

    How do you remove dependencies? I want to remove the dependencies so I can reinstate them using the same dll files.

    I put my output onto a text file and view it view Notepad. These functions are in agLibraryOutput.
    . Project1 depends on agLibraryOutput
    . Library2 also depends on agLibraryOutput
    . Project1 also depends on Library2.

    There are two agOutputLibrary files, one in the bin folder and the other in the obj folder:
    • agOutputLibrary > bin > debug > net6.0 > agOutputLibrary.dll
    • agOutputLibrary > obj > debug > net6.0 > agOutputLibrary.dll

    I am getting ambiguous file references error. It could be because I have created dependencies sometimes using the dll in the bin folder and other times in the obj folder.

    When I click on a project/library in the solutions file I see code like:

    <ItemGroup>
    <Reference Include="agOutputLibrary">
    <HintPath>..\agOutputLibrary\obj\Debug\net6.0\agOutputLibrary.dll</HintPath>
    </Reference>
    </ItemGroup>

    To delete a reference do I delete from <Reference include … > to </reference>

    Visual basic in visual studio 2022

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How do you remove dependencies.

    NEVER use the obj folder. That is temporary output used in the build process. It is basically irrelevant to you. The bin folder is the final output and that is what you should be using. That said, if the projects are in the same solution, reference the project rather than the output DLL.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How do you remove dependencies.

    You ought to be adding and removing references in the Solution Explorer, not editing the project file directly.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2011
    Location
    Melbourne
    Posts
    37

    Re: How do you remove dependencies.

    ** About editing dependencies in the solution explorer.
    . I have now seen that double clicking dependencies shows an assemblies line and under that each of the project dependencies.
    . I can delete dependencies from here.
    . Thanks

    ** Use the dll file from the bin folder – not the obj folder. Thanks

    You say “if the projects are in the same solution, reference the project rather than the output DLL.” What does this mean?

    When I right-click dependencies to “add a shared project reference”. When I browse the only files that can go into “file name” are dll files not project files.

    In solution explorer I have:

    . Solution “TestDistributions” (3 of 3 projects)

    VB agDistributionLibrary
    Dependencies

    VB agHistogramLibrary
    Dependencies

    VB agOutputLibrary
    Dependencies

    VB TestDistributions
    Dependencies

    When I deleted the dependencies in each of my Libraries and only put dependencies into TestDistribitions, I get lots of errors.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How do you remove dependencies.

    Quote Originally Posted by Persist View Post
    When I right-click dependencies to “add a shared project reference”. When I browse the only files that can go into “file name” are dll files not project files.
    Who said anytying about shared projects? Right-click the Dependencies node, select Add Project Reference and then check the project(s) that you want to reference. You will then always be using the latest build of that project output and you can debug into it just as you can the startup project.
    Quote Originally Posted by Persist View Post
    When I deleted the dependencies in each of my Libraries and only put dependencies into TestDistribitions, I get lots of errors.
    Of course you get errors if you haven't referenced something you depend on. Every project needs a reference to everything that it directly depends on. That's what a dependency is.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2011
    Location
    Melbourne
    Posts
    37

    Re: How do you remove dependencies.

    I have been going around in circles on this all day. There is probably something simple that I am missing or I am doing too much and double-defining causing ambiguity.

    My agOutputLibrary public subroutines are shown as ambiguous: ErrorsBC30561. These subroutines are used in two of the libraries and in the main project.

    This is what I have done:

    Right-click each Dependency > add project reference > tick each to always be using the latest build

    Right-click Dependencies > add shared project references, the dll files from the bin folder.

    Right-click Solution > Add > Existing projects > Project files

    Right-click Solution > Project dependencies > tick each Library used

    Right-click Solution > Project build order > check

    Right-click Solution > Rebuild solution (does this rebuild each library too?)

    Click each Project line to check
    . Namespace (comes from project name)
    . for net 6.0
    . project references: project names
    . project references: dll files from bin folders

    I hope someone can spot a fix.

  7. #7
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,958

    Re: How do you remove dependencies.

    Quote Originally Posted by Persist View Post
    I have been going around in circles on this all day. There is probably something simple that I am missing or I am doing too much and double-defining causing ambiguity.

    My agOutputLibrary public subroutines are shown as ambiguous: ErrorsBC30561. These subroutines are used in two of the libraries and in the main project.

    This is what I have done:

    Right-click each Dependency > add project reference > tick each to always be using the latest build

    Right-click Dependencies > add shared project references, the dll files from the bin folder.

    Right-click Solution > Add > Existing projects > Project files

    Right-click Solution > Project dependencies > tick each Library used

    Right-click Solution > Project build order > check

    Right-click Solution > Rebuild solution (does this rebuild each library too?)

    Click each Project line to check
    . Namespace (comes from project name)
    . for net 6.0
    . project references: project names
    . project references: dll files from bin folders

    I hope someone can spot a fix.
    If the projects are part of the same solution then for each project you simply right click on the dependencies section and go to "Addd Project Reference..." and tick the projects it is dependant on, make sure you only tick the ones it is dependant on not just all of them.

    There is no need to do anything regarding shared project references.

    If you build the solution then it should build all the projects in the correct order.

  8. #8

    Thread Starter
    Member
    Join Date
    Dec 2011
    Location
    Melbourne
    Posts
    37

    Re: How do you remove dependencies.

    I have spent further days struggling with this. Here I am trying to understand how to set up library projects and avoid my ambiguous file errors.

    At one stage, my program was running! I think the program started giving these ambiguous file errors and sometimes other errors after I added my output file library to the solution.

    For each library project that uses another library (my output file library) do you go to:
    . solution explorer > dependencies > add shared project references.

    For each of these library projects, do you insert an imports statement for the libraries that this library project used in each dot vb file within the project?

    Do you set up a library differently depending on whether you (1) add the library project to the main project solution, or (2) do not do this adding? I have now tried both 1 and 2.

    When the library has been added to the main project solution do you rebuild each library from within the compound solution file and then run the main project.

    Here the main project and Library1 and Library2 all use my output file library - because they each write to my output file. I now have three OutputLibrary.dll files, i.e.,
    VB2\Library1\bin\debug\net6.0\OutputLibrary.dll
    VB2\Library2\bin\debug\net6.0\OutputLibrary.dll
    VB2\OutputLibrary\bin\debug\net6.0\OutputLibrary.dll

    I hope you can help.

  9. #9
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,958

    Re: How do you remove dependencies.

    Quote Originally Posted by Persist View Post
    I have spent further days struggling with this. Here I am trying to understand how to set up library projects and avoid my ambiguous file errors.

    At one stage, my program was running! I think the program started giving these ambiguous file errors and sometimes other errors after I added my output file library to the solution.

    For each library project that uses another library (my output file library) do you go to:
    . solution explorer > dependencies > add shared project references.
    No. Not shared project reference, you want the Add Project Reference - both myself and jmc have already said this.

    Quote Originally Posted by Persist View Post
    For each of these library projects, do you insert an imports statement for the libraries that this library project used in each dot vb file within the project?
    only to simplify referring to types defined in a namespace, this has nothing to do with the dependencies directly.

    Quote Originally Posted by Persist View Post
    Do you set up a library differently depending on whether you (1) add the library project to the main project solution, or (2) do not do this adding? I have now tried both 1 and 2.
    You would add the project as a dependency project to whichever projects use it as a dependency. I am not entirely sure what you mean by "do not do this adding".

    Quote Originally Posted by Persist View Post
    When the library has been added to the main project solution do you rebuild each library from within the compound solution file and then run the main project.
    Visual Studio should handle building everything in the correct order for you when you do a "Rebuild Solution"

    Quote Originally Posted by Persist View Post
    Here the main project and Library1 and Library2 all use my output file library - because they each write to my output file. I now have three OutputLibrary.dll files, i.e.,
    VB2\Library1\bin\debug\net6.0\OutputLibrary.dll
    VB2\Library2\bin\debug\net6.0\OutputLibrary.dll
    VB2\OutputLibrary\bin\debug\net6.0\OutputLibrary.dll

    I hope you can help.
    I am assuming you are getting the OutputLibrary.dll in each of these folders as well as the project output, in that case don't worry about them - VS is just making sure any needed dependencies are present alongside the dlls that use them. You shouldn't need to care about any of this if you have done as we have suggested and just added the project references.
    Last edited by PlausiblyDamp; Apr 17th, 2023 at 01:19 PM.

  10. #10

    Thread Starter
    Member
    Join Date
    Dec 2011
    Location
    Melbourne
    Posts
    37

    Re: How do you remove dependencies.

    I got my programmes and the libraries running by creating new projects for the main program and each library. Then adding dependencies as you said.

    Solution explorer > dependencies > add project reference > browse
    C:\Users\MyName\Documents\VB2\MyLibrary1\bin\Debug\net6.0\MyLib.dll

    i included the imports statements

    It worked & I thought I was in the clear but when I added another library and I got more errors.

    In my main program I went:
    VS > build > clean solution
    VS > build > rebuild solution
    It worked again.

    Thanks for your help

  11. #11

    Thread Starter
    Member
    Join Date
    Dec 2011
    Location
    Melbourne
    Posts
    37

    Re: How do you remove dependencies.

    Resolved. Thanks.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width