- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有什么
MyGraphicsLibrary.Content.Pipeline.dll
public class MyModelProcessor { }
public class MyModelContent { }
[ContentTypeWriter]
public class MyModelContentWriter : ContentWriter<MyModelContent>
{
protected override void Write(ContentWriter output, MeshDataContent value)
{
value.Write(output);
}
public override string GetRuntimeType(TargetPlatform targetPlatform)
{
return "MyGraphicsLibrary.MyModel, MyGraphicsLibrary";
}
public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
return "MyGraphicsLibrary.MyModelReader, MyGraphicsLibrary";
}
}
MyGraphicsLibrary.dll:强命名
public class GraphicsDeviceControl : System.Windows.Forms.Panel { }
public class MyModel { }
public class MyModelReader : ContentTypeReader<MyModel> { }
GraphicsDeviceControl
基于 this XNA sample .
ActiveXApplication.dll:强命名,已注册 COM Interop
[Guid("")]
[ProgId("ActiveXApplication.ActiveXControl")]
[ComVisible(true)]
public class ActiveXControl : System.Windows.Forms.UserControl { }
public class MyGraphicsDeviceControl : MyGraphicsLibrary.GraphicsDeviceControl { }
ActiveXControl
是我在 IE7/8 中使用 <object>
嵌入的应用程序的主 UI标签。托管控件的站点已添加到受信任的站点。 MyGraphicsDeviceControl
根据传递给 ActiveXControl
的信息加载模型从网页。加载的模型是使用 MyModelProcessor
从 FBX 模型创建的并写成 MyModelContentWriter
.我目前正在使用 XNA 3.0。
问题
当 MyGraphicsDeviceControl
执行以下行:
this.contentManager.Load<MyModel>("modelName")
我收到以下错误:
Error loading "pathToModel\modelName". Cannot find ContentTypeReader MyGraphicsLibrary.MyModelReader, MyGraphicsLibrary.
使用ActiveXControl
时不会出现此错误在 Windows 窗体应用程序中。当使用默认的 XNA 模型类时,错误不会发生(我正在尝试使用自定义模型类而不是滥用 XNA 模型类的 Tag 属性)。使用 Reflector,我追踪了 ContentManager.Load<T>
查找异常源并发现它发生在 XNA 尝试调用 Type.GetType()
时使用 MyModelContentWriter.GetRuntimeReader()
中定义的字符串返回 null。
问题
关于在 IE 中运行时尝试加载 MyModelReader 而不是 XNA 的 ModelReader 时 Type.GetType() 为何返回 null 的任何想法?
更新:
在进一步研究这个问题之后,我找到了一种方法让我的自定义模型类在 IE 中运行时加载。通过为 AppDomain.AssemblyResolve
添加处理程序,我能够返回包含 MyModelReader
的程序集这允许 Type.GetType()
调用 XNA 代码即可成功。
根据我阅读的有关反射和程序集加载的信息,我假设我能够毫无问题地使用 XNA 模型类,因为 XNA 程序集已在 GAC 中注册,而我的则没有。然而,MyGraphicsLibrary.dll
已经加载到 AppDomain
中,所以我不完全确定为什么它无法解析程序集。我假设它与加载它的上下文有关,但我不确定程序集在 IE 中运行时加载的上下文。
最佳答案
将 ContentManager.RootDirctory 设置为绝对路径。
关于c# - XNA ActiveX 控件 - 在 IE 中运行时找不到自定义 ContentReader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4306759/
我有什么 MyGraphicsLibrary.Content.Pipeline.dll public class MyModelProcessor { } public class MyModelCo
我是一名优秀的程序员,十分优秀!