.net-assembly

Are signed .net assemblies ever fully verified when loaded, to check they haven't been modified?

一曲冷凌霜 提交于 2019-12-06 07:28:07
问题 I used to think that .net assemblies that were signed and/or strong-named were verified by the CLR when loaded, meaning that it wasn't possible for someone to edit the IL and still have a valid assembly. Then I listened to this great Herding Code podcast where Jon McCoy said that doesn't really happen (approx 12:47 in the podcast) - i.e. anyone can edit the IL and mess with your assembly and the CLR will not care. I know this sounds weird, but he seems to know what he's talking about, so

Is Assembly.LoadFrom keeping an open file handle?

早过忘川 提交于 2019-12-06 05:12:56
I am loading another assembly using Assembly.LoadFrom("path.exe"); and after that i cant seem to delete that exe from the file system. so i was wondering if this path keeps an open file handle and how i can close it? Cédric Bignon Yes, it is open until the assembly is unloaded from the appdomain. If you really need to delete the file, load its content into memory. The use Assembly.Load(byte[]) to load the assembly: using (Stream stream = File.OpenRead("path.exe")) { byte[] rawAssembly = new byte[stream.Length]; stream.Read(rawAssembly, 0, (int)stream.Length); Assembly.Load(rawAssembly); } By

PowerShell Binary Module assembly dependency error

此生再无相见时 提交于 2019-12-06 04:28:57
问题 I am developing PowerShell binary module . It uses Json.NET and other libraries. I am getting this exception "Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.' On hard drive I have an updated version of it (version 7.0.2) Problems like that are easily solved in console, web or desktop application, with app.config or "web.config" via lines like this

ASP.NET Core 5.0 error CS0012: The type 'Object' is defined in assembly 'mscorlib

不羁的心 提交于 2019-12-06 04:13:03
问题 In Visual Studio 2015 I have a kproj, in this project I wanted to add a reference to an assembly that is not available in any public nuget package source, so I've created my own nuget package and this way was able to add the reference to this assembly. The problem is that now I'm getting the following exception: ASP.NET Core 5.0 error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral,

How do I load a Class Library DLL at runtime and run a class function using VB.NET?

允我心安 提交于 2019-12-06 04:05:39
Say I've a class like this inside a class library project called SomeClass- Public Class SomeClass Public Function DoIt() as String Return "Do What?" End Function End Class I get a SomeClass.dll which I want to load at runtime from another Windows Forms Application, and then have it call the DoIt() function and show it's value in a messagebox or something. How do I do that? I suggest to make DoIt shared, since it does not require class state: Public Class SomeClass Public Shared Function DoIt() as String Return "Do What?" End Function End Class Then calling it is easy: ' Loads SomeClass.dll

Server Error in '/' Application. System.Web.Http.WebHost

家住魔仙堡 提交于 2019-12-06 00:59:34
I'm trying to publish an ASP.NET MVC 4 Internet Application. After it's been published, I go ahead and click the link for my website and find this: Server Error in '/' Application. Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO

How to detect a missing .NET reference at runtime?

拜拜、爱过 提交于 2019-12-06 00:52:41
问题 My application contains references to an external library (the SQL Server Management Objects). Apparently, if the library is not present on the run-time system, the application still works as long as no methods are called that use classes from this library . Question 1: Is this specified behaviour or just a (lucky) side effect of the way the CLR loads libraries? To detect whether the reference is accessible, I currently use code like this: Function IsLibraryAvailable() As Boolean Try

MEF, why are identical duplicates of one and the same exported plugin created?

十年热恋 提交于 2019-12-05 18:53:30
(1) Using the code below I get exactly 2 items in my containers of one and the same exported plugin and I wonder why: (2) Additional question which I really cannot implement: How can I extend the framework to handle different plugin types (such as having several imports of different types, or one import that stores all plugins in a dynamic IEnumerable or so). I want to provide in my static wrapper class one generic method that returns the discovered plugin as a function of type and matching meta data. The exported plugin (which resides in a separate dll and whose location is pointed to when

Why does the compiler when using an overload in another assembly sometimes require you to also reference a subassembly?

人盡茶涼 提交于 2019-12-05 16:49:33
There are quite a few questions/answers about the compiler error mentionend below and how to resolve it, but the question here is asking about some insights why in this case this is required. Why does a project A which uses an overload of a method of another referenced project B, which uses an object of project C in one of it's overloaded signatures require, that you reference project C from project A, even if you never use the object from project C? I guess it must have to do with the resolving of which overload to use, but I'd like to understand the concept behind. Here's an example: Put

Automate AssemblyFileVersion Incrementation using GIT

我是研究僧i 提交于 2019-12-05 16:16:11
Ok I understand that this is probably not conventional, but that aside: I am using the AssemblyFileVersion as kind of my "Build Name" string. It is formated like this: ' File Version information for an assembly consists of the following four values: ' ' Year ' Month ' Day ' Commit Number for that day ' ' Build Name can either be alpha | beta | hotfix | release ' alpha - is a development buildname with rapid changing API ' beta - is a production build for our beta users ' hotfix - is a production version with a bug fix ' release - is a standard issue production version. <Assembly: