assembly-resolution

Debugging error “The Type 'xx' is defined in an assembly that is not referenced”

你离开我真会死。 提交于 2019-12-04 08:57:34
问题 The full error is as follows: The type 'System.Windows.Forms.Control' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. and it points at the very first statement (an Debug.Assert line) in the very first class in a library project that doesn't need System.Windows.Forms (or so I thought). I know how to solve it: add the mentioned reference. But how do I find out what

Mimicking assembly resolution of the msbuild process

此生再无相见时 提交于 2019-12-04 08:20:09
I am writing a validation tool that checks the versions of files referenced in a project. I want to use the same resolution process that MSBuild uses. For example, Assembly.Load(..) requires a fully-qualified assembly name. However, in the project file, we may only have something like "System.Xml". MSBuild probably uses the project's target framework version and some other heuristics to decide which version of System.Xml to load. How would you go about mimicking (or directly using) msbuild's assembly resolution process? In other words, at run-time, I want to take the string "System.Xml", along

How can I dynamically reference an assembly that looks for another assembly?

谁说我不能喝 提交于 2019-12-04 05:25:17
Apologies for the dodgy question - happy to rephrase if someone has a better suggestion. I'm trying to create an object by dynamically invoking an assembly belonging to another application. The following PowerShell code is working nicely for me: [Reflection.Assembly]::LoadFrom("C:\Program Files\Vendor\Product\ProductAPI.dll") $bobject = new-object ProductAPI.BasicObject $bobject.AddName("Some Name") I'm struggling to do the same thing in C#. Based on other posts on StackOverflow I currently have this: System.Reflection.Assembly myDllAssembly = System.Reflection.Assembly.LoadFile("C:\\Program

Does redirecting assembly binding work for unit testing with a test runner?

▼魔方 西西 提交于 2019-12-03 01:44:53
Ok, so here's the full description of the problem I'm having: I am trying to use NUnit ExtensionMethods but whenever I run a test containing one of the extension methods using TestDriven.Net or if I just flat out try to load the assembly using a test-runner GUI (Icarus or NUnit) I get a FileNotFoundException. Pounding head against a wall and digging in further I think I know what's wrong. Cue reflector and yep, I can see that NUnit.Framework>ExtensionMethods.dll has a reference to nunit.framework, Version=2.4.6.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77 and my current version of nunit

How to reference assembly from web.config?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 02:54:12
I need to add reference to 'System.XML.dll' assembly into web.config (in order to try solution for problem, mentioned here: Problem with Extension method: IXmlLineInfo ). I've tried to add the following line into "assemblies" section: <add assembly="System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"/> That caused an error: Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Could not load

How to reference assembly from web.config?

随声附和 提交于 2019-12-02 02:52:24
问题 I need to add reference to 'System.XML.dll' assembly into web.config (in order to try solution for problem, mentioned here: Problem with Extension method: IXmlLineInfo). I've tried to add the following line into "assemblies" section: <add assembly="System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"/> That caused an error: Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error

Adding assembly reference requires base assembly to be referenced as well

故事扮演 提交于 2019-12-02 02:49:23
问题 I created a assembly having a child class that derives from a parent defined in another assembly. When I add reference to the child, Visula studio also requires reference to be added to the parent. Why is it so and how can I prevent it without losing any functionality? 回答1: In C/C++, class definition is present in a .h header file. That gives you ability to reference information about a class (as needed e.g. when you want to inherit from that class) without the need to source file with

Adding assembly reference requires base assembly to be referenced as well

断了今生、忘了曾经 提交于 2019-12-02 01:28:54
I created a assembly having a child class that derives from a parent defined in another assembly. When I add reference to the child, Visula studio also requires reference to be added to the parent. Why is it so and how can I prevent it without losing any functionality? In C/C++, class definition is present in a .h header file. That gives you ability to reference information about a class (as needed e.g. when you want to inherit from that class) without the need to source file with implementation information. The downside is code duplication (implementation in .cpp file needs to repeat most of

System.BadImageFormatException occurred when build in Release Mode

跟風遠走 提交于 2019-12-01 23:39:24
I am referencing an exe file in a dll. When run in DEBUG mode everything runs fine but when run in Release mode below exception is thrown System.BadImageFormatException occurred HResult=-2147024885 Message=Could not load file or assembly 'Presensoft.InlineMarker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. Source=Presensoft.ApplicationServer FileName=Presensoft.InlineMarker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null FusionLog==== Pre-bind state information === LOG: DisplayName =

silverlight 4, dynamically loading xap modules

牧云@^-^@ 提交于 2019-12-01 18:08:17
I know that it is possible to load xap modules dynamically using Prism or MEF framework. However, I'd like not to use those frameworks; instead load my xap files manually. So, I created the following class (adapted from internet): public class XapLoader { public event XapLoadedEventHandler Completed; private string _xapName; public XapLoader(string xapName) { if (string.IsNullOrWhiteSpace(xapName)) throw new ArgumentException("Invalid module name!"); else _xapName = xapName; } public void Begin() { Uri uri = new Uri(_xapName, UriKind.Relative); if (uri != null) { WebClient wc = new WebClient()