activator

Activator.CreateInstance throws ArgumentNullException for parameter 'Type'

大兔子大兔子 提交于 2019-12-10 10:55:47
问题 I recently encountered a problem with my Profile provider: it wouldn't retrieve profiles correctly (see error below). It worked locally, but when I put the code compiled by a Web Deployment project on a server it would crash. Value cannot be null. Parameter name: type 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. Strack Trace:

LinkedIn:用Gradle构建Java Play框架应用

余生颓废 提交于 2019-12-10 09:20:34
在LinkedIn,我们一直在评估最好的开发框架和工具来开发伟大的产品。11年的历史中,我们使用过很多前端web框架-如 Grails 、Frontier(LinkedIn内部的web框架),最近是: Play !我们喜欢 Play ,并热情地在公司内部推行起来。于是我们用Play进行了整合和扩展。现在我们正在评估哪个构建系统(build system,下同)更好用。 这篇文章介绍了用在Play中用Gradle来支持开发,及Gradle的目前状态和它的初步特性的演化。我们希望Play社区提供更多反馈以帮助Gradle类软件的开发。能够给Sbt和Gradle开发Play应用将提供更多的自由度和多样性。 背景:代码的组织 在LinkedIn,我们用代码仓库管理公共API和服务,每个这种仓库我们给它取了个名叫 Multiproduct ,每个Multiproduct通过独立的 Ivy 来组织,默认的名称是com.linedin。LinkedIn的部分代码已经开源了,如 databus 。 用Multiproducts来组织代码的结果是,它们都是多工程的构结构,每个Multiproduct有10个或100个工程,同时每个工程又有多个 构件(artifacts,下同)。 在LinkedIn,我们的Play应用在classpath路径下有超过500个jar包

Activator.CreateInstance() troubles

冷暖自知 提交于 2019-12-07 12:39:26
问题 I have a factory that is supposed to create objects that inherit from class Foo at run-time. I would think that System.Activator.CreateInstance's return type was the same as the type of an object it's creating, but judging from the following error message, its return type is Object. Error 1 Cannot implicitly convert type 'object' to 'cs_sandbox.Foo'. An explicit conversion exists (are you missing a cast?) F:\projects\cs_sandbox\Form1.cs 46 24 cs_sandbox OK, so maybe I am missing a cast, but

Activator.CreateInstance throws ArgumentNullException for parameter 'Type'

岁酱吖の 提交于 2019-12-06 12:48:46
I recently encountered a problem with my Profile provider: it wouldn't retrieve profiles correctly (see error below). It worked locally, but when I put the code compiled by a Web Deployment project on a server it would crash. Value cannot be null. Parameter name: type 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. Strack Trace: [ArgumentNullException: Value cannot be null. Parameter name: type] System.Activator.CreateInstance(Type type, Boolean

System.Activator.CreateInstance returning null

徘徊边缘 提交于 2019-12-06 02:31:20
The problem I have is that CreateInstance returns null. Here is the code: if(spattmono[0] != null) { if((SpecialAttack) System.Activator.CreateInstance( spattmono[0].GetClass()) == null) { Debug.Log("DUMB ACTIVATOR!!!"); } //combo.SetSpecialAttack(spattack); } Attack and SpecialAttack are both classes that store basic information, and inherit from UnityEngine.Object . Attmono and spattmono are both MonoScript arrays, attmono being able to hold 16 and spattmono being able to hold 4. They get there information from these. for(int at = 0; at < numberOfAttacks; ++at ) { attmono[at] = (MonoScript)

Activator.CreateInstance can't find the constructor (MissingMethodException)

泪湿孤枕 提交于 2019-12-03 22:46:39
I have a class which has the following constructor public DelayCompositeDesigner(DelayComposite CompositeObject) { InitializeComponent(); compositeObject = CompositeObject; } along with a default constructor with no parameters. Next I'm trying to create an instance, but it only works without parameters: var designer = Activator.CreateInstance(designerAttribute.Designer); This works just fine, but if I want to pass parameters it does not: var designer = Activator.CreateInstance(designerAttribute.Designer, new DelayComposite(4)); This results in an MissingMethodException : Constructor voor type

Create object based on XmlChoiceIdentifier

走远了吗. 提交于 2019-12-02 08:27:04
问题 I am creating objects dynamically using Activator(C#) and one of these classes looks like: class Driver { Driver() { } [XmlChoiceIdentifier("ItemElementName")] [XmlElement("Bit16", typeof(DriverModule))] [XmlElement("Bit32", typeof(DriverModule))] [XmlElement("Bit64", typeof(DriverModule))] [XmlElement("Unified", typeof(DriverUnified))] public object Item { get; set; } [XmlIgnore] public ItemChoiceType ItemElementName { get; set; } // ... other serialization methods } When I create instance

InvalidCastException of a Activator.CreateInstance object during an installation procedure

浪尽此生 提交于 2019-12-02 03:49:36
I have the following procedure private static IMyInterface OpenInstance( string assemblyPath, string classType, string assemblyName, out AppDomain domainInstall) { IMyInterface interface = null; AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = assemblyPath; domainInstall = AppDomain.CreateDomain("PathInstall", null, domaininfo); ObjectHandle handleService = null; try { handleService = Activator.CreateInstance( domainInstall, assemblyName, classType, true, System.Reflection.BindingFlags.CreateInstance, null, new Object[] { assemblyName}, System.Globalization

Can I use Activator.CreateInstance with an Interface?

风格不统一 提交于 2019-11-30 17:59:08
I have an example: Assembly asm = Assembly.Load("ClassLibrary1"); Type ob = asm.GetType("ClassLibrary1.UserControl1"); UserControl uc = (UserControl)Activator.CreateInstance(ob); grd.Children.Add(uc); There I'm creating an instance of a class, but how can I create an instance of a class which implements some interface? i.e. UserControl1 implements ILoad interface. U: I can cast object to interface later, but I don't know which type in the assemblies implements the interface. This is some code i have used a few times. It finds all types in an assembly that implement a certain interface: Type[]

C# Using Activator.CreateInstance

家住魔仙堡 提交于 2019-11-30 06:09:12
问题 I asked a question yesterday regarding using either reflection or Strategy Pattern for dynamically calling methods. However, since then I have decided to change the methods into individual classes that implement a common interface. The reason being, each class, whilst bearing some similarities also perform certain methods unique to that class. I had been using a strategy as such: switch (method) { case "Pivot": return new Pivot(originalData); case "GroupBy": return new GroupBy(originalData);