由于自定义内容处理器,我需要以编程方式更改模型的内容处理器或从解决方案/项目更改fbx文件属性(XNA Framework内容管道 - >内容处理器)。 这就是因为我希望使用该程序的用户添加他的皮肤模型并更改此属性。 如果问题含糊不清或重复,请提前致谢并道歉。
更新
通过一些研究,我发现了一种用于访问项目的解决方案,但遗憾的是在尝试将项目项目放入我的解决方案/项目中时出现错误..仍然可以访问项目属性(避免尝试更改它们)。
这里是代码(类似于MSDN模板):
static void Main(string[] args)
{
EnvDTE80.DTE2 dte;
object obj = null;
System.Type t = null;
t = System.Type.GetTypeFromProgID("VisualStudio.DTE.11.0", true);
obj = System.Activator.CreateInstance(t, true);
dte = (EnvDTE80.DTE2)obj;
string solutionFile =
"C:\\Users\\The Wizard Of Code\\Documents\\Visual Studio 2012\\Projects\\ConsoleApplication2\\ConsoleApplication2.sln";
MessageFilter.Register();
//dte.MainWindow.Activate();
/*Problem I think*/
Solution2 soln = (Solution2)dte.Solution;
soln.open(solutionFile);
Console.WriteLine(soln.Item(1).ProjectItems.Item(1).Name);
dte.Quit();
MessageFilter.Revoke();
}
错误讯息: 消息过滤器指示应用程序正忙。 (来自HRESULT的异常:0x8001010A(RPC_E_SERVERCALL_RETRYLATER))
更新2 消息过滤器类: 公共类MessageFilter:IOleMessageFilter { // //包含IOleMessageFilter的类 //线程错误处理函数。
// Start the filter.
public static void Register()
{
IOleMessageFilter newFilter = new MessageFilter();
IOleMessageFilter oldFilter = null;
CoRegisterMessageFilter(newFilter, out oldFilter);
}
// Done with the filter, close it.
public static void Revoke()
{
IOleMessageFilter oldFilter = null;
CoRegisterMessageFilter(null, out oldFilter);
}
//
// IOleMessageFilter functions.
// Handle incoming thread requests.
int IOleMessageFilter.HandleInComingCall(int dwCallType,
System.IntPtr hTaskCaller, int dwTickCount, System.IntPtr
lpInterfaceInfo)
{
//Return the flag SERVERCALL_ISHANDLED.
return 0;
}
// Thread call was rejected, so try again.
int IOleMessageFilter.RetryRejectedCall(System.IntPtr
hTaskCallee, int dwTickCount, int dwRejectType)
{
if (dwRejectType == 2)
// flag = SERVERCALL_RETRYLATER.
{
// Retry the thread call immediately if return >=0 &
// <100.
return 99;
}
// Too busy; cancel call.
return -1;
}
int IOleMessageFilter.MessagePending(System.IntPtr hTaskCallee,
int dwTickCount, int dwPendingType)
{
//Return the flag PENDINGMSG_WAITDEFPROCESS.
return 2;
}
// Implement the IOleMessageFilter interface.
[DllImport("Ole32.dll")]
private static extern int
CoRegisterMessageFilter(IOleMessageFilter newFilter, out
IOleMessageFilter oldFilter);
}
[ComImport(), Guid("00000016-0000-0000-C000-000000000046"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
interface IOleMessageFilter
{
[PreserveSig]
int HandleInComingCall(
int dwCallType,
IntPtr hTaskCaller,
int dwTickCount,
IntPtr lpInterfaceInfo);
[PreserveSig]
int RetryRejectedCall(
IntPtr hTaskCallee,
int dwTickCount,
int dwRejectType);
[PreserveSig]
int MessagePending(
IntPtr hTaskCallee,
int dwTickCount,
int dwPendingType);
}
抱歉代码加载
更新3
我设法进入属性但它们是文件属性而不是我在右键单击某个项目或解决方案上的项目时得到的属性,并在右下角获取该选项卡(我需要通过代码执行)
答案 0 :(得分:0)
[STAThread] 在main之前似乎解决了这个问题 src:http://msdn.developer-works.com/article/11266583/why+looping+through+projectitems+sometimes+causes+Exception+from+HRESULT%3A+0x8001010A+(RPC_E_SERVERCALL_RETRYLATER) ....
<强>更新强> modelviewer.codeplex.com 得到了我需要的东西。