使用 New Atlanta 的 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]]
有没有办法使用创建泛型类型的实例?