Share via


Invalid class string Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))

Question

Friday, September 27, 2013 8:21 AM

Dear Sir or Mam,

i think i have a very 'special' problem regarding 0x800401F3.

I'm trying to execute the following code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;

namespace PublishingPointTester
{
    public partial class Form1 : Form
    {

        // Declare variables.
        WMSServer Server;
        IWMSBroadcastPublishingPoint BCPubPoint;
        IWMSPublishingPoints PubPoints;
        IWMSPublishingPoint PubPoint;
        Type tServerType;
        WMSServer RemoteServer;

        public Form1()
        {
            InitializeComponent();


            try
            {
                Type tServerType = Type.GetTypeFromProgID("WMSServer.Server.9", true);

                // Create a new WMSServer object.
                // Server = new WMSServer();

                RemoteServer = (WMSServer)Activator.CreateInstance(Server.GetType());

                // Retrieve the IWMSPublishingPoints object.
                PubPoints = RemoteServer.PublishingPoints;

                // Retrieve each publishing point and retrieve the
                // IWMSBroadcastPublishingPoint object.
                for (int i = 0; i < PubPoints.Count; i++)
                {
                    PubPoint = PubPoints[i];

                    if (PubPoint.type ==
                        WMS_PUBLISHING_POINT_TYPE.WMS_PUBLISHING_POINT_TYPE_BROADCAST)
                    {
                        BCPubPoint = (IWMSBroadcastPublishingPoint)PubPoint;

                        // Retrieve the current status of the publishing point.
                        // The status is reported as the result of a bitwise OR
                        // of any of the designated values.
                        WMS_BROADCAST_PUBLISHING_POINT_STATUS ppsStatus;
                        ppsStatus = BCPubPoint.BroadcastStatus;

                        // If the publishing point is currently stopped, start it.
                        if (ppsStatus == WMS_BROADCAST_PUBLISHING_POINT_STATUS.WMS_BROADCAST_PUBLISHING_POINT_STOPPED)
                        {
                            MessageBox.Show("Publishing Point gestoppt!!!");
                        }
                        break;
                    }
                }
            }
            catch (COMException comExc)
            {
                textBox1.Text = comExc.ToString();
            }
            catch (Exception e)
            {
                textBox1.Text = e.ToString();
            }
        }
    }
}

When this function is called i get the error:

Type tServerType = Type.GetTypeFromProgID("WMSServer.Server.9", true);

It gives me the HRESULT: 0x800401F3. Now there are different aproaches to solve this problem in the forums. I've looked in the registry and WMSServer.Server.9 should be registered correctly.

Here the Values:

HKEY_CLASSES_ROOT\CLSID\{845FB959-4279-11D2-BF23-00805FBE84A6} : (Standard) REG_SZ Windows Multimedia Service Center

HKEY_CLASSES_ROOT\CLSID\{845FB959-4279-11D2-BF23-00805FBE84A6} : AppID REG_SZ {A2EFA5CB-3B0E-11D2-9EFD-006097D2D7CF}

    HKEY_CLASSES_ROOT\CLSID\{845FB959-4279-11D2-BF23-00805FBE84A6}\ProgID : (Standard) REG_SZ WMSServer.Server.9

    HKEY_CLASSES_ROOT\CLSID\{845FB959-4279-11D2-BF23-00805FBE84A6}\Programmable : (Standard) REG_SZ (no value)

    HKEY_CLASSES_ROOT\CLSID\{845FB959-4279-11D2-BF23-00805FBE84A6}\TypeLib : (Standard) REG_SZ {D71E02C2-41EF-11D2-BF23-00805FBE84A6}

    HKEY_CLASSES_ROOT\CLSID\{845FB959-4279-11D2-BF23-00805FBE84A6}\Version : (Standard) REG_SZ 9.0

    HKEY_CLASSES_ROOT\CLSID\{845FB959-4279-11D2-BF23-00805FBE84A6}\VersionIndependentProgID : (Standard) REG_SZ WMSServer.Server

I'm using Visual Studio 2010 Ultimate X64 on a Windows 2008 Enterprise Server with installed IIS and Streaming Media-Services.

Any help would be greatly appreciated.Thanks in advance

Edit: I've tried to run Visual Studio with administrator privileges but the problem exists further.

All replies (4)

Friday, September 27, 2013 11:48 AM | 1 vote

Try the following recipes

http://social.microsoft.com/Forums/it-IT/09b532ab-cc3c-45b9-b413-607bf67d18ca/errors-with-gacutil

and see whether it helps,

wizend


Friday, September 27, 2013 8:52 PM

I've already tried GACUTIL and REGSVR32, nothing changed my situation.

And something like:

static class NativeMethods
{
        [DllImport("kernel32.dll")]
        public static extern IntPtr LoadLibrary(string dllToLoad);

        [DllImport("kernel32.dll")]
        public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);

        [DllImport("kernel32.dll")]
        public static extern bool FreeLibrary(IntPtr hModule);
}

class Program
{
        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
        private delegate int MultiplyByTen(int numberToMultiply);

        static void Main(string[] args)
        {
                IntPtr pDll = NativeMethods.LoadLibrary(@"PathToYourDll.DLL");
                //oh dear, error handling here
                //if (pDll == IntPtr.Zero)

                IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "MultiplyByTen");
                //oh dear, error handling here
                //if(pAddressOfFunctionToCall == IntPtr.Zero)

                MultiplyByTen multiplyByTen = (MultiplyByTen)Marshal.GetDelegateForFunctionPointer(
                                                                                        pAddressOfFunctionToCall,
                                                                                        typeof(MultiplyByTen));

                int theResult = multiplyByTen(10);

                bool result = NativeMethods.FreeLibrary(pDll);
                //remaining code here

                Console.WriteLine(theResult);
        }
} 

doesn't work, because I need a function call to get this running. But all I want to do is to create an instance of a WMSServer.

But sometimes your Answer may help for others, so I mark your answer as helpul. Thank you.


Saturday, September 28, 2013 12:13 PM

I've double checked if i had registered the WMSServerTypeLib.dll with regsvr32 and maybe something went wrong. Now it should be registered properly, but when I now try to execute my program, it gives me another error:

[MissingMethodException: No parameterless constructor defined for this object.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
   System.Activator.CreateInstance(Type type, Boolean nonPublic)
   System.Activator.CreateInstance(Type type)
   at PublishingPointTester.Form1..ctor() in c:\Users\Entwickler\Documents\Visual Studio 2012\Projects\PublishingPointTester\PublishingPointTester\Form1.cs:Line 34

what is the problem now? The error references to this line:

RemoteServer = (WMSServer)Activator.CreateInstance(tServerType.GetType());

Please help. :-)


Thursday, December 3, 2015 4:00 PM | 1 vote

I know this topic is out of date, but I will treat that as a note to myself.

Had the same issue with invoking COM+

If you know the GUID you can try call:

Type.GetTypeFromCLSID(classId, true);

instead of:

Type.GetTypeFromProgID("WMSServer.Server.9", true);

It did the trick in my case.