Can't install a modified assembly in Global Assembly Cache - .net-assembly

Using dnSpy assembly editor I modified a copyrighted IBM assembly (DLL). I fixed a bug in the source code. After compiling the code back to a DLL, I tried to install it into the GAC.
But during this, InstallAssembly threw the following error:
InstallAssembly failed with error -2146234299
Anyone knows what this means? Thanks for any help!
EDIT
On learn.microsoft.com I can see that -2146234299 means FusionErrorSignatureCheckFailed. So it is not possible for me to modify the DLL?

I'm very glad you're not able to do this 🤓. This is exactly what's intended:
Assemblies deployed in the Global Assembly Cache must have a strong name. When an assembly is added to the Global Assembly Cache, integrity checks are performed on all files that make up the assembly. The cache performs these integrity checks to ensure that an assembly has not been tampered with, for example, when a file has changed but the manifest does not reflect the change.
Source: Global Assembly Cache

If you modify an assembly, its signature will no longer be valid.
You would have to create a new signature for it, but you won't be able to do that because you don't have access to the private key that IBM used when they created the original signature.
So I'm afraid you're out of luck.

Related

Calling C DLL's compiled with SAFESEH set to no from Inno Script

I have an existing DLL that is working fine when being called from Inno Script however I need to add a function that calls another third party library (of which I do not have the source code).
Whenever I do that I get a 'could not call proc' error.
In order to compile (in Visual Studio) my DLL with the added function, I have to set SAFESEH to no because of the third party library. Is this likely to be what stops Inno Script from working? Are there any options available to resolve this?
Thanks in advance
Turning off SafeSEH is unlikely to prevent anyone from calling your function.
It is more likely that the 3rd-party library added a dependency to some DLL (MSVC run-time etc.). Use Dependency Walker to check if your imported DLLs change after you add the 3rd-party library.

Acumatica Publishing with DLL resulting in System.BadImageFormatException

I am trying to add some external DLLs to the Acumatica Customisation project but upon publishing it results in "System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid."
Error Image:
I already have added multiple DLLs to the Customisation. And was using the method specified here: Acumatica unable to publish the Customization Package to skip over the errors, but in this case it does not seem to be working.
The first step should be identifying which DLL is the culprit. I suggest you create an empty project and put the files in there one by one with the ignore rules. Maybe you missed to add ignore rule for one of the files.
This error happens because Acumatica attempts to parse the DLL as a .Net framework assembly. If you add non .Net assembly such as native x86/x64 compiled libraries you need to add the ignore rule so Acumatica doesn't attempt to parse it.
If the error is coming from a DLL you compiled, make sure it was compiled in Any CPU platform. This prevents any incompatibility related to 32 bit/64 bit mismatch.

MonoDevelop is Removing My Reference to System.Drawing (Unity)

In one of my scripts it is required that I reference System.Drawing. However it seems every time I start up the project and enter Mono it's removed the reference and I need to re-add it.
All my other references stay where they should be, any particular reason this may be happening or how I would prevent it?
Unity regenerates the .csproj.sln files automatically whenever the filesystem changes which will overwrite any change you have made to your .csproj.sln.
Unity uses information from the Unity project and the filesystem to do this so you have to use a method Unity understands for your changes to be preserved. For example, preprocessor flags have to be defined through the Unity project and assemblies have to be added via the filesystem.
I believe if you drop your dlls into ./Assets/Dlls then they will be included in the project. However, I suspect System.Drawing will not be supported because its an incompatible drawing library.

Plugin registration tool throwing Unable to load plug-in assembly

I'm using the latest version of the MS CRM 2011 SDK and am trying to deploy a custom workflow activity (it has been signed with a key). The plugin registration tool throws an error "Unable to load plug-in assembly" without much information about the root cause.
The error trace thrown by the tool is very similar to the one described in this post
The answer to the post referenced above indicates adding Microsoft.Xrm.Client assembly in the GAC, but my workflow project references the following DLLs
1)Microsoft.Crm.Sdk.Proxy.dll
2)Microsoft.Xrm.Sdk.dll
3)Microsoft.Xrm.Client.dll
4)Microsoft.Xrm.Sdk.Workflow.dll
Should all these be added to the GAC?
The CRM server is Win 2K8R2. I tried dragging and dropping the assemblies to the c:\windows\assembly folder but that did not work. No errors but nothing was copied over either. I followed the instructions outlined in this post but that did not work either.
What am I missing?
I don't think you should have to place any crm dlls into the gac, they are already installed in the CRM server files. If you think it might solve the problem use gacutil (not clear if you can't install to the gac, or if that didn't fix the problem).
I suspect its complaining about your dll, are you trying to register to the disk? As you usually have to place the dll in the crm/server/bin folder first. Try deploying to the database - makes life easier for deploying the solution to other servers later.
If that still doesn't work post the trace of the error.
Turn on crm server side.tracing. You'll get much better error information. Use the CRM diagnostic tool to turn on trace logging: http://crmdiagtool2011.codeplex.com
Turns out that if you use the /codecustomization switch to have the code generator derive from "CrmOrganizationcContext", you need "microsoft.xrm.client.dll". This DLL is not included in the default install of CRM and you need to get this on the server one wa or another.
I decided against using the /codecustomization switch which causes the "context" to derive from "OrganizationContext" instead and not take a dependency on that DLL. Plugin registration now works! This post provides more insight

Error serializing with ServiceStack JSON on MonoTouch

I am experimenting with ServiceStack's JSON engine. I grabbed the MonoTouch binary build, v2.20. Works fine from simulator, but from the iOS device (iPad2, iOS5) I get an exception thrown by the type initializer for JsonWriter (and not much other than that). I am using MonoTouch 5, MonoDevelop 2.8.1, and targeting iOS 5. I have disabled library linking because I am getting an error when enabled.
I created a sample and uploaded to https://github.com/t9mike/ServiceStack-JSON1.
I'm trying to determine whether the issue is my compilation options, Service Stack, or MonoTouch. Thanks in advance.
A quick partial answer that might help:
I have disabled library linking because I am getting an error when enabled.
The current (5.0) managed linker can eliminate some unused (from a static analysis point of view) code from your application. This generally occurs when using Link all option, i.e. where user code gets processed by the linker.
One alternative is using the Link SDK assemblies only that won't touch the user code (only the code shipped with MonoTouch itself will be processed by the linker).
Another alternative is adding [Preserve] attributes on your code to ensure the serializer requirements are still met after the linker has processed your code. More information about the linker and [Preserve] attributes can be found here.
The next (5.2) release of MonoTouch will include a bit more sophisticated step in the linker to ensure the basic XML serialization and DataContract requirements are not broken. Not sure if this will solve this specific case (ServiceStack JSON) but I'll have a look into it.
As for the rest of your question I'll try to build this myself and duplicate your issue.
I ended up grabbing the ServiceStack.Text sources from GitHub, version 3.0.3. I created a new MonoTouch library project. I had to tweak ServiceStack.Text/JsConfig.cs slightly to conditionalize away the System.Drawing.Color bits. I'll send a patch and MT csproj to the authors.
After using this new assembly, my sample MT app ran fine on the device. I have updated my sample at https://github.com/t9mike/ServiceStack-JSON1 with the new ServiceStack.Text dll.

Resources