开发者

Create c# instance of generic type using <cfobject> in BlueDragon.NET's implementation of ColdFusion

Using New Atlanta's BlueDragon.NET implementation of ColdFusion, we have the ability to create instances of C# .NET objects using the cold fusion tag. For example:

<cfobject name="list" type=".net" action="CREATE"
 class="System.Collections.ArrayList">

In one case, however, we need to create an instance of a generic type. This works for internal types like System.Int32:

<cfobject name="list" type=".net" action="CREATE"
 class="System.Collections.Generic.List`1[[System.Int32]]">

But, when using our own assembly-qualified class, like the following:

namespace Foo.Bar.Bam
{
    public class MyClassName
}

that is compiled to the assembly Foo.Bar.dll and used like so:

<cfobject name="list" type=".net" action="CREATE"
 class="System.Collections.Generic.List`1[[Foo.Bar.Bam.MyClassName,Foo.Bar]]">

it fails with an "BlueDragon Internal Server Error" with the following stack trace:

java.lang.ClassNotFoundException: Could not load file or assembly 'Foo.Bar]]' or one of its dependencies. The system cannot find the file specified.
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.AppDomain.Load(String assemblyString)
   at com.nary.util.ClassUtils.forName(String className)
   at com.naryx.tagfusion.cfm.tag.cfOBJECT.render(cfSession session)
   at com.naryx.tagfusion.cfm.tag.cfTag.coreRender(cfSession _Session)
   at com.naryx.tagfusion.cfm.engine.cfSession.onRequest(cfFile requestFile)
   at com开发者_如何学JAVA.naryx.tagfusion.cfm.engine.cfEngine.service(cfSession _Session)

Without the assembly qualification, it fails with a CFML error:

Failed to load class, System.Collections.Generic.List`1[[Foo.Bar.Bam.MyClassName]]

Is there any way to create an instance of a generic type using ?


You must specify the name of your Assembly (dll) not the keyword Assembly.

Given:

namespace Me
{
   public class Foo { }
}

and compiling to MyStuff.Dll; the class would be

class="System.Collections.Generic.List`1[[Me.Foo, MyStuff]]">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜