How to change item properties programmatically (Content Processor XNA 4.0 )?

0

I need to change the content processor of my models programmatically or the fbx file property (XNA Framework Content Pipeline->Content Processor) from the solution/project because of the custom content processor. And that's all because I want the user who uses this program to add his skinned model and change this property. Thanks in advance and my apologies if the question is vague or repetitive.

Update

With some research I found a solution sort of for accessing the project but unfortunately getting an error while trying to get the projectitems inside my solution/project .. still can access project properties (haven't tried changing them).

here's the code (which was like MSDN template):

    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();

    }

The error message : The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))

Update 2 Message filter class: public class MessageFilter : IOleMessageFilter { // // Class containing the IOleMessageFilter // thread error-handling functions.

    // 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);
}

sorry for the load of code

Update 3

I managed to get to the properties but they were the file properties not the properties I get when I right click on the item on some project or solution and get that tab on the bottom right (which I need to do through code).

c#
visual-studio-2012
xna
xna-4.0
projectitem
asked on Stack Overflow Feb 24, 2015 by AbdelRahman Badr • edited Feb 26, 2015 by AbdelRahman Badr

1 Answer

0

[STAThread] before main seems to fix the issue src : http://msdn.developer-works.com/article/11266583/why+looping+through+projectitems+sometimes+causes+Exception+from+HRESULT%3A+0x8001010A+(RPC_E_SERVERCALL_RETRYLATER)....

Update modelviewer.codeplex.com had what I needed.

answered on Stack Overflow Feb 26, 2015 by AbdelRahman Badr • edited Mar 2, 2015 by AbdelRahman Badr

User contributions licensed under CC BY-SA 3.0