.net-assembly

C# dynamic compilation and “Microsoft.CSharp.dll” error

拈花ヽ惹草 提交于 2019-12-01 16:58:10
问题 I'm doing the example that can be found here. So I'm trying to run IronPython in a C# script: Python: def hello(name): print "Hello " + name + "! Welcome to IronPython!" return def add(x, y): print "%i + %i = %i" % (x, y, (x + y)) return def multiply(x, y): print "%i * %i = %i" % (x, y, (x * y)) return C#: using IronPython.Hosting; using IronPython.Runtime; using Microsoft.Scripting.Hosting; using System; namespace IntroIronPython { class IronPythonMain { static void Main(string[] args) { //

How to add reference to assembly in vs2012

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 16:14:12
I need help on how to correctly add assembly in C# code. I start a blank project and trying to run the simple code below. but has referencing errors. I know by default system.dll is included under the references folder. so why is it still complain that "'System.Configuration is not been referenced"? Am I missing some manual steps? If so how do I do it? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Net.Configuration; namespace ConsoleApplication2 { class Program { static void Main(string[] args) {

Is it correct to add a reference to an assembly that is not directly used by the project?

寵の児 提交于 2019-12-01 12:10:18
I have a solution composed by 3 projects. one for Entity framework that contains my edmx diagram one for my core business and one for my web app When I publish my code on a server or hosting service I get this runtime error: {"Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.":"EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"} I get this error because my entity framework assemblies is not published. The entity framework dll

Create class instance in assembly from string name

半城伤御伤魂 提交于 2019-12-01 10:44:32
I'm not sure if this is possible, and I'm quite new to using assemblies in C#.NET. What I would like to do is to create an instance of a class when supplied the string name of that class. Something like this: using MyAssembly; namespace MyNameSpace { Class MyClass { int MyValue1; int MyValue2; public MyClass(string myTypeName) { foreach(Type type in MyAssembly) { if((string)type == myTypeName) { //create a new instance of the type } } AssignInitialValues(//the type created above) } //Here I use an abstract type which the type above inherits from private void AssignInitialValues(AbstractType

Get interfaces implemented by class

孤人 提交于 2019-12-01 09:16:25
I'm doing assembly analysis project and I encountered a problem. What I want to achieve is list of all interfaces implemented by a class, but without derived interfaces (and interfaces implemented by derived classes). Here's an example to illustrate (from LinqPad, .Dump() is a printing to result window): void Main() { typeof(A).GetInterfaces().Dump(); //typeof(IT), typeof(IT<Int32>) typeof(B).GetInterfaces().Dump(); //typeof(IT<Int32>) typeof(C).GetInterfaces().Dump(); //typeof(IT), typeof(IT<Int32>) } class C : A {} class A : IT {} class B : IT<int> {} public interface IT : IT <int> {} public

Could not load file or assembly 'file:///C:\\WINDOWS\\Microsoft.NET\\Framework\\v4.0.30319\\ asp.net vs2010

我的未来我决定 提交于 2019-12-01 08:55:40
Yesterday my project was running smoothly but today I'm facing an error. Here are the details: Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\parktms\c8392404\1ba3bab5\App_Web_login.aspx.6cc23264.lmj8uym6.dll' or one of its dependencies. The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE)) 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

Get interfaces implemented by class

孤者浪人 提交于 2019-12-01 06:58:24
问题 I'm doing assembly analysis project and I encountered a problem. What I want to achieve is list of all interfaces implemented by a class, but without derived interfaces (and interfaces implemented by derived classes). Here's an example to illustrate (from LinqPad, .Dump() is a printing to result window): void Main() { typeof(A).GetInterfaces().Dump(); //typeof(IT), typeof(IT<Int32>) typeof(B).GetInterfaces().Dump(); //typeof(IT<Int32>) typeof(C).GetInterfaces().Dump(); //typeof(IT), typeof(IT

BinaryFormatter ignore assembly version

天涯浪子 提交于 2019-12-01 06:43:17
I have the following method to generate a hash of an object. It works pretty good! But when I change the version of the assembly, the hash is changing even when the object is the same. public static string GetHash(Object item) { MemoryStream memoryStream = new MemoryStream(); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, item); binaryFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple; HashAlgorithm hashAlgorithm = new MD5CryptoServiceProvider(); memoryStream.Seek(0, SeekOrigin.Begin); return Convert.ToBase64String(hashAlgorithm

c# get assembly executable directory

扶醉桌前 提交于 2019-12-01 06:14:30
I have 2 application. Example App1 and App2 When run nomal App1 will show assembly executable location. But when i call App1 from App2, it return App2 start up location. So, how to get App1 start up path when call App1 from App2? You can get the directory of the currently executing assembly with this: string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); GetExecutingAssembly() returns the currently executing assembly and Location is the full path or UNC path of that assembly. Path.GetDirectoryName() returns the directory of a full path. Note that the assembly's

BinaryFormatter ignore assembly version

元气小坏坏 提交于 2019-12-01 06:03:33
问题 I have the following method to generate a hash of an object. It works pretty good! But when I change the version of the assembly, the hash is changing even when the object is the same. public static string GetHash(Object item) { MemoryStream memoryStream = new MemoryStream(); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, item); binaryFormatter.AssemblyFormat = FormatterAssemblyStyle.Simple; HashAlgorithm hashAlgorithm = new