Linking a resource file to an existing .NET assembly using Assembly Linker - c#

I am trying to link the file name.ext to assembly.dll using the AL (Assembly Linker) to mimic what can be done in C++ using the /ASSEMBLYLINKRESOURCE option.
The syntax I am using is the following:
al.exe assembly.dll /link:name.ext
and I get the following error:
ALINK: error AL1017: No target filename was specified
I also tried:
al.exe assembly.dll /out:outAssembly.dll /link:name.ext
getting the following error:
ALINK: warning AL1020: Ignoring included assembly 'assembly.dll'
ALINK: error AL1019: Metadata failure while creating assembly -- The system cannot find the file specified.
What I am doing wrong? What is the correct syntax to obtain the resource link?
Thanks.

The Assembly Linker generates a file that has an assembly manifest from one or more files that are either modules or resource files. A module is an intermediate language (IL) file that does not have an assembly manifest.
assembly.dll can not be the source of Assembly Linker because it already is an assembly with manifest. So you get this
ALINK: warning AL1020: Ignoring included assembly 'assembly.dll'

Related

Error Message: From Assembly Cannot Embed Interop Types from Assembly

Im using .NET Framework 4.8 and Im using the ClosedXML Library,but my programm is an class Library type of programm so that the dll of the programm will land in an different folder where all other additional dll like the closedXML dll are not allowed to be there in that folder. So if i want to execute the dll I get error message that the Assembly references not are found, which is logic because in the other folder all the dll like closedXML are not in the folder and cant be referenced.
So what I tried to do is to embedded the Interop Type set to true.
But when I set it to true I get these two Error Messages:
Error CS1747 Interoptypes cannot be embedded from assembly "DocumentFormat.OpenXml, Version=2.19.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17" because the System.Runtime.InteropServices.GuidAttribute attribute is missing.
and
Error CS1759 Cannot embed interoptypes from assembly "DocumentFormat.OpenXml, Version=2.19.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17" because either the System.Runtime.InteropServices.ImportedFromTypeLibAttribute attribute or the System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute attribute is missing.
what I tried to fix this problem was at first rebuild entire solution and install the dll new.
And I tried to add this Code to the assemblyinfor.cs file:
[assembly: System.Runtime.InteropServices.Guid("2e197457-53cd-4261-81b6-07c65281b2a3")]
[assembly: PrimaryInteropAssembly(1, 0)]
but I get the Error message still, all the dll are on the newest version.
Someone an Idea how to set the Interop Type to true without getting this Error message?

Could not locate the assembly when using absolute path

I'm trying to add an assembly reference to my project in Rider, and when doing so, I can normally navigate to the desired folder and select the .dll. The selected .dll immediately appears under assemblies, despite having a warning sign next to it (hovering over it yields no extra information). When trying to build, I get the following error:
Microsoft.Common.CurrentVersion.targets(2127, 5): [MSB3245] Could not resolve this reference. Could not locate the assembly "Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
The same happens if I try to build the project from terminal using either xbuild or msbuild. If it makes any difference, I'm using Linux.

Why does my Visual Studio Online build keep failing?

For some reason it keeps failing because it can't find some assemblies and I don't understand why it can't find them. It's an ASP.NET MVC application.
In the build definition my Source Settings is set to the src/ folder which contains the projects in my solution and the packages folder.
The build process template is TfvcTemplate.12.xaml which I'm pretty sure is one of the defaults.
Clean workspace: true
Label sources: true
Projects: My application's solution file
Clean build: true
Output location: SingleFolder
My errors are as follows
Controllers\CompanyController.cs (11): The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?)
Global.asax.cs (7): The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Services\ExcelExportService.cs (8): The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?)
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "Antlr3.Runtime". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "EPPlus". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "System.Web.Optimization". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "WebGrease". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
I checked deeper into the logs and I can see that it's trying to find them but all it gets is "Considered blablablabla, but it didn't exist."
Why can't it find my nuget packages?

Unknown build error, 'Could not load file or assembly 'System.Windows

I am trying to build a test project for silverlight application. When i build this project it throws following error
Unknown build error, 'Could not load file or assembly 'System.Windows, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
I have system.winwos dll in my references and i am using visual studio 2012.
What should i do to resolve this error
More Details:
If I remove system.windows.control.Navigation dll, this error no longer comes up but build requires system.windows.control.Navigation.
Finally found a system.windows version 5.0.5.0 in C:\Program Files (x86)\Microsoft Silverlight\5.1.20913.0 folder
Had to add this file manually in project.csproj file using tag
Getting other build errors not but at least the this one is resolved.
Thanks for all your help!
Generally when I've had this problem it's because my application is set to build 64-bit rather than AnyCpu and the offending assembly is 32-bit. Or vice versa.

using .NET Assemblies in Delphi

I am currently required to open and use a .NET assembly in delphi. The Assembly that i am trying to use also has an assembly of objects it is using. With the object assembly i was able to use regasm to create a type library. I was also able to assign a SN and register it with the GAC.
Now with the main assembly i am tyring to use in Delphi, i try using regasm and i end up getting an error "Regasm : error RA0000 : Unable to locate input assembly [location] or one of its dependencies." I have looked over the location and file name and there is nothing wrong. Am i missing a step somewhere?
Are you sure all the assemblies your assembly references are in the GAC?

Categories