Try to change all the project reference to nuget package reference - c#

I have to move one of the library A out of project(which has lot's of library project in one solution) . library A contains lot's of project reference. So for moving that out i have to first have a nugget package for those project reference. For that i have created one
wrapperlibrary which will contains those project reference and then converted that to nuget. Then i have included only that nuget inside library A so that it can have those dll. There are total 6 project reference in which 5 are working fine but 6th one is creating an issue given below.
"The type A is defined in assembly that is not referenced. You must add a reference to assembly "projectName Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
When i try to add that projectName as a nuget(package) reference then also i am getting same issue but when i add that "projectName" as a project(.csproj) reference then everything is working. Can anyone please let me know how can i resolve above issue.
If you need more details then please let me know so that i can add it here.

Related

Multi-targetted Library (monoandroid, xamarinios) issue with System.ComponentModel.DataAnnotations

I'm converting a (working) .netstandard library project into a multi-targetted project that will target:
<targetframeworks>netstandard2.1;xamarinios10;monoandroid10.0;monoandroid12.0;</targetframeworks>
I'm having issues with the System.ComponentModel.DataAnnotations reference. Sepcifically I get this error (for eveything except the .netstandard target):
The type 'DataType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel.DataAnnotations, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
After a bit of searching I tried adding the System.ComponentModel.Annotations (4.7.0) nuget package. This gave the same error.
In the nuget directory for this I noticed that where the .dll would normally live it had a file '.' - I didn't know if that was important (.nuget\packages\system.componentmodel.annotations\4.7.0\ref\MonoAndroid10) - the .netstandard dll was there as expected.
I've also noticed that (a separate) Xamarin.Android project seems to use the System.ComponentModel.DataAnnotations.dll which lives in C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0
I'm not sure if the right version of Mono.Android (or ios equivalant) is being targetted or I have to specify a specific assembly version, or whether I'm down the wrong track completely?
Thanks in advance,
Paul.
As the comment above mentions, to workaround this issue, I moved the bit of offending code (that used the System.ComponentModel.DataAnnotations) into a seperate project that targetted .netstandard2.1 and then referenced this project from my multi-targetted project.

Microsoft.Web.Infrastructure already exist but cannot find reference

I have cloned a project from repository, After resolving other references issues I am stuck at
Could not load file or assembly 'Microsoft.Web.Infrastructure,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
the Package 'Microsoft.Web.Infrastructure' is already installed but I can not find its reference and neither I can uninstall this package
Update
I have accidentally removed that reference and now I cannot find that reference
This is because Microsoft.Web.Infrastructure is not in your GAC.
Add this reference (Microsoft.Web.Infrastructure) to your project as the following.
Right click the reference.
Go to properties.
Set copy to local to true.
Finally I created an other ASP.NET MVC empty project and copy
Microsoft.Web.Infrastructure.dll
file to the bin folder of this project and it worked for me

Could not load file or assembly 'GMap.NET.Core, Version=1.7.5.0

I am trying to load a map on my project. I'm using WPF on my project but since I can't use the "Overlays" I'm using to put a marker, and it's working on WindowsForm, I am now using it and calling it to the WPF form, until I encountered this error.
Could not load file or assembly 'GMap.NET.Core, Version=1.7.5.0,
Culture=neutral, PublicKeyToken=b85b9027b614afef' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
I look in my references, and I only have a reference to GMap.NET.Core version 1.7.0.0.
Can anybody please help me should I solve this?
You need to just download the project of Gmap.Net from here next extract the project files open Release-NETv(any_version)
this contain assembly of Gmap.Net.Core ,so just add reference of this assembly in your project.
Here is what happens when assemblies not matches this is not same problem but will help you understand.
Example Of Incorrect Reference
Error
Solution
To solve this kindly open your app config file and see the version number of gmap package there then check the version number of gmap inside your references if they not match delete dll from references and change the version number to 1.7.5.0 in your appconfig then rebuild project visual studio automatically restore the missing assemblies so they will be same on both sides
For your better understanding please look this screen shot when I have an assembly in references uses version which is less the version is being use in project appconfig.
When you install a package from package manager it goes inside package folder of your application to add this,delete the reference from references if contain old version then add latest version from package folder.
Error Solve
By changing the version in appconfig the error was gone.
3 yers later lol
replace this value on app.config
Example assemblyIdentity name="GMap.NET.Core" publicKeyToken="b85b9027b614afef" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.7.5.0" newVersion="1.7.5.0"

Strong Name for Microsoft.Practices.Composite-DLL leads to compiler error

I would like to sign all projects in my C# solution. But when I try to do so, there is the problem, that several third party assemblies don't have a strong name. These assemblies are:
Microsoft.Practices.Composite.dll
Microsoft.Practices.Composite.Presentation.dll
After doing some research I found a way to give third party DLLs a strong name (source):
1) ildasm /all /out=ThirdParty.il ThirdParty.dll
2) ilasm /dll /key=YourKey.snk ThirdParty.il
These operations both complete successful. But when I remove the NuGet packages with the unsigned assemblies from my projects and add the signed ones as references, I get the following compiler error:
The type 'Microsoft.Practices.Composite.Events.EventBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Practices.Composite, Version=2.0.1.0, Culture=neutral, PublicKeyToken=null'
But of course I already added Microsoft.Practices.Composite.Presentation.dll
To confine the problem, I tried to add the reference to a new project. But since I got the same error there, I can exclude some weird configuration in my main solution.
You can download my test-project here: https://www.dropbox.com/s/g7sqb4vtbnasfjz/ConsoleApplication1.zip?dl=0
I really hope that you can help me in any way.
Today I found out that the Composite Library is part of Prism since version 4. So instead of adding references to the dlls signed by me, I added the NuGet Package for Prism, which is already signed.

System.Windows.Interactivity must be referenced in the main project

So I have a WPF project and my interface in a different project than the main one. I went to reference System.Windows.Interactivity, but it would not work. Not until I added it as a reference to the main project as well...
This is the first time this has ever happened with any reference I have added. What makes this one so special?
EDIT:
By wouldn't work... This is the error.
{"Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."}
System.Windows.Interactivity.dll is not in the GAC, so .Net doesn't know where to find it.
By adding a reference to your main project, you make the build system copy the DLL to the output folder.
This lets the runtime find it.

Categories