通过使用新亚特兰大的ColdFusion的BlueDragon.NET实现,我们能够使用冷融合标签创建C# .NET对象的实例。例如:
<cfobject name="list" type=".net" action="CREATE"
class="System.Collections.ArrayList">然而,在一种情况下,我们需要创建一个泛型类型的实例。这适用于像System.Int32这样的内部类型:
<cfobject name="list" type=".net" action="CREATE"
class="System.Collections.Generic.List`1[[System.Int32]]">但是,当使用我们自己的程序集限定类时,如下所示:
namespace Foo.Bar.Bam
{
public class MyClassName
}它被编译成程序集Foo.Bar.dll,并像这样使用:
<cfobject name="list" type=".net" action="CREATE"
class="System.Collections.Generic.List`1[[Foo.Bar.Bam.MyClassName,Foo.Bar]]">它会失败,并显示"BlueDragon内部服务器错误“,并显示以下堆栈跟踪:
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.naryx.tagfusion.cfm.engine.cfEngine.service(cfSession _Session)如果没有程序集限定,它将失败,并显示CFML错误:
Failed to load class, System.Collections.Generic.List`1[[Foo.Bar.Bam.MyClassName]]有没有办法用来创建泛型类型的实例?
发布于 2011-06-04 06:41:15
必须指定程序集(dll)的名称,而不是关键字Assembly。
给定:
namespace Me
{
public class Foo { }
}并编译成MyStuff.Dll;这个类应该是
class="System.Collections.Generic.List`1[[Me.Foo, MyStuff]]">https://stackoverflow.com/questions/6233298
复制相似问题