Share via


How to add proper version of DLL to the project?

Question

Wednesday, December 11, 2019 10:29 AM

Hello folks,

Have one more strange question for you.

I use a log4net logger tool in my projects.
Packages not used, do update manually.
Tool updated and latest version is 2.0.8.0. Used build with old signing key.
Reference to the DLL in the projects was replaced by removing and adding reference. 

Studio 2015 Community did this without any problem and properties window show that proper version added.
But application begin fail on ClickOnce installation.

I review the prroject and find following:

    <Reference Include="log4net, Version=1.2.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\log4net\v.2.0.8\log4net.dll</HintPath>
    </Reference>

I review other projects and find references for 1.2.10.0 version of log4net. 
I was not able to replace this reference using Studio 2015 - each time I remove the DLL and add it again a wrong version are scribed in the project file.

Version 1.2.10.0 and version 1.2.12.0 of log4net.dll are in the GAC, but as far as I known this should not affect scripting a reference in the project.

Can anybody tell me how to get proper reference script in the project? 

P.S. Studio 2019 Community also installed on the system.

Sincerely, Highly skilled coding monkey.

All replies (13)

Thursday, December 12, 2019 3:27 AM

Hi Andrey,

Thank you for posting here.

Not sure how do you install and refer to log4net tool, and do you use NuGet Packages?

I have tested in my side by creating two projects in one solution and right-click my project -> Manage NuGet Packages… -> then browse and install different versions of log4net packages to each of my project (It will help to add references to my project automatically).

After that, I get two different references and point to the specified version of log4net. I checked that and it looks like below.

<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=XXXXXXXX, processorArchitecture=MSIL">

  <HintPath>..\packages\log4net.1.2.10\lib\2.0\log4net.dll</HintPath>

  <Private>True</Private>

</Reference>

And in the other project it looks like this.

<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken= XXXXXXXX, processorArchitecture=MSIL">

  <HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>

  <Private>True</Private>

</Reference>

I noticed that the codes you shared with us have two different version numbers, and the HintPath is different from mine.

If you add NuGet Package like what I said above, you could follow below steps to clean all caches of this NuGet packages and then try to reinstall it again to solve this issue.

#1. Right-click your project -> Unload Project -> right-click again -> Edit XXXX.XXproj -> find and delete the codes from <Reference Include=”log4net…” to </Reference>

#2. Right-click your project -> Reload Project -> select and click packages.config file -> find and delete this code line <package id=”log4net” version=”2.0.8” targetFramework=”netXXX” />

#3. Right-click your project and click “Open Folder in File Explorer” -> close VS 2015 -> find bin and obj folder then delete them.

#4. Go to this path C:\Users\username]\nuget\packages and delete all folders under this path.

#5. Try to reinstall NuGet Package(log4net) again(after installing, a dialog may appear and please choose no) and check if this issue could be solved.

I hope all above could help you and any feedback would be great expected.

Sincerely,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Thursday, December 12, 2019 9:35 AM

Hello Tianyu,

>do you use NuGet Packages?
Packages not used, do update manually.

Sorry, do not have time to look how NuGet work from command line.

But - YES - with NuGet reference will be scripted properly.

Still not understand why it didn't work properly on adding reference to the DLL in Studio.

Best regards,

Andrey

Sincerely, Highly skilled coding monkey.


Friday, December 13, 2019 7:52 AM

Hi Andery,

Thank you for your feedback.

If possible, could you share me with the detailed steps to reproduce your issue and I will then go to test in my side.

We are looking forward to hearing from you.

Sincerely,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Friday, December 13, 2019 9:31 AM

Simple.

Put one (or several earlier) version of Dll into GAC.

In Studio add different (latest) version to the project.

Save project and look on the file content.

That's all. 

Optional - solution may have more that one project.

Yestarday had opposite situation - was not able to get proper DLL from correct reference - all the time was picked up version from GAC. Fixed by removing reference from Studio and adding again. Nightmare...

Sincerely, Highly skilled coding monkey.


Tuesday, December 17, 2019 7:01 AM

Hi Andrey,

Thank you for sharing us with the steps to reproduce.

I am blocked at the step of “add reference”, after I put dll into GAC, I didn’t find it from “add references” even under Browse tag. Do I miss something? Or maybe I need to modify the registry of Windows system?

Looking forward to hearing from you.

Best Regards,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Tuesday, December 17, 2019 9:24 AM

> after I put dll into GAC, I didn’t find it from “add references” even under Browse tag.

Sorry,

you add one (old) version to GAC.

you add different (new) version to project.

I can understand "missing dll", but if dll file is there Browse would allow to find and add it.

>Or maybe I need to modify the registry of Windows system?

I didn't do anything with Registry regards to old and/or new versions of log4net.dll.

Sincerely, Highly skilled coding monkey.


Wednesday, December 25, 2019 8:26 AM

Hi Andrey,

Really sorry for delay in reply.

I could reproduce your issue in my side, after checking your reminder.

I consider this issue is caused by clutter of referencing dll files(of course, I mean VS itself). You could remove the log4net dll from “References” under project, then right-click “References” and add reference -> Browse again -> find and select the log4net v 2.0.8 in file explorer, then re-add it.

I hope this could help you and any feedback will be greatly expected.

Sincerely,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Tuesday, January 7, 2020 9:03 AM

Hello,

Vacation ended - back to work.

Before:

    <Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\log4net\v.1.2.13\log4net.dll</HintPath>
    </Reference>

Library can't be added second time. After removal and re-adding of dll:

After:

    <Reference Include="log4net, Version=1.2.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\log4net\v.2.0.8.0\log4net.dll</HintPath>
    </Reference>

Sincerely, Highly skilled coding monkey.


Wednesday, January 8, 2020 9:24 AM

Hello Andrey,

Thank you for your feedback.

If you try to Rebuild your solution after removal and re-adding of dll will it be a little different?

Any feedback will be expected.

Sincerely,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Wednesday, January 8, 2020 12:07 PM

No. Try different solution, try cleaning of bin, obj, .vs - no difference.

Sincerely, Highly skilled coding monkey.


Thursday, January 9, 2020 9:51 AM

Hi Andrey,

What about changing  “Version=1.2.12.0” to “Version=2.0.8.0” manually, after removing and re-adding log4net(v2.0.8) ?

Hope this could help you.

Sincerely,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Thursday, January 9, 2020 12:50 PM

Hmmm...

Manually - Yes, can do... actually - did to have system working... spend a week...

I have for the moment more than 200 projects and all the times (after each project Save?) need to look was dll added correctly or something give gleech and reference came to be incorrect? 

May be somebody confirm the gleech and open a ticket for it to fix this problem? Most likely problem is in order of DLL search - Hint used after GAC was searched. 10 min to find a place and change the order... 

Sincerely, Highly skilled coding monkey.


Friday, January 10, 2020 8:35 AM

Hi Andrey,

Thank you for your feedback.

I apologize for my suggestion and I have reported this issue to the Visual Studio product team. This is the link and you could follow/vote/comment below that thread and see the update there.

Hope this could help you.

Sincerely,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].