locked
Generate UUID Programmatically RRS feed

  • Question

  • I am creating a COM Server Programmatically.  How can I generate UUID programmatically.

    Since, I could not do it programmatically.  I created it from the Tools->Create GUID dialog and manually added to my IDL file.  

    But it does not work too.

     

    I got the following error:

     

    Deployment and/or registration failed with error: 0x8973190e. Error writing file '%CSIDL_PROGRAM_FILES%\NServer\NServer.dll'. Error 0x80450001: (null)

     


    uma shankar
    • Edited by Shanuma Monday, December 12, 2011 12:42 AM
    Monday, December 12, 2011 12:41 AM

Answers

  • What is the failure code from CoCreateInstance?  From the error you have above it seems the dll isn't being registered, which means CoCreateInstance would fail as the proper data isn't in the registry for it to know what dll the class factory lives in.  As I said before are you running VS as admin when loading your solution (that builds the COM dll) so that regsvr has access to write to the proper registry hive and the deployment step can write to %ProgramFiles%?

    Ryan

    • Marked as answer by Shanuma Tuesday, January 10, 2012 11:16 AM
    Monday, December 12, 2011 6:50 PM

All replies

  • It is unclear what you mean by this

    >I am creating a COM Server Programmatically.

    A COM server is just an exe/dll that exports a class factory (or class factories).  What do you mean you are 'creating a COM server programatically'?  You mean you are creating a COM object programatically (i.e. via CoCreateInstance)?

    You can dynamically create GUIDs via CoCreateGuid (that is all Tools->Create Guid is doing), but if you are creating a COM object it needs to have a stable GUID for registration or no one could use it.

    >Deployment and/or registration failed with error: 0x8973190e. Error writing file '%CSIDL_PROGRAM_FILES%\NServer\NServer.dll'. Error 0x80450001: (null)

    I am not sure what this has to do with anything in the rest of your post.  The fact you created a Guid via Tools->Create Guid didn't cause this error, wherever it is coming from.

    For more information you would need to provide more information about what you are hoping to accomplish, or perhaps a short and simple repro.

    Ryan

    Monday, December 12, 2011 2:11 AM
  • I am sorry.  I want to create a COM Object.  I have created the idl file programmaticatically.

    But, I need to change the UUID given below:  These UUIDs does not work, which gives me the error:

     

    >Deployment and/or registration failed with error: 0x8973190e. Error writing file '%CSIDL_PROGRAM_FILES%\NServer\NServer.dll'. Error 0x80450001: (null)

     

    // ATLTutor.idl : IDL source for ATLTutor
    //
    
    // This file will be processed by the MIDL tool to
    // produce the type library (ATLTutor.tlb) and marshalling code.
    
    import "oaidl.idl";
    import "ocidl.idl";
    
    [
    	object,
    	uuid(3A450DD1-E910-4f7c-9C69-9836CF4DC196),
    	helpstring("IHello Interface"),
    	pointer_default(unique)
    ]
    interface IHello : IUnknown{
    	[helpstring("method Hello")] HRESULT Hello(void);
    };
    [
    	uuid(9A603241-3C36-4d38-9F3C-206A0211B1F0),
    	version(1.0),
    	helpstring("ATLTutor 1.0 Type Library")
    ]
    library ATLTutorLib
    {
    	importlib("stdole2.tlb");
    	interface IDocHostUIHandlerDispatch;
    	interface IAxWinAmbientDispatchEx;
    	[
    		uuid(71B3EECF-96A6-43d6-8636-A7AF32F625E8),
    		helpstring("Hello Class")
    	]
    	coclass Hello
    	{
    		[default] interface IHello;
    	};
    };
    
    

     


    uma shankar
    • Edited by Shanuma Monday, December 12, 2011 10:23 AM
    Monday, December 12, 2011 10:22 AM
  • I want to create a COM Object.  I have created the idl file programmaticatically.

    But, I need to change the UUID given below:  These UUIDs does not work, which gives me the error:

     

    >Deployment and/or registration failed with error: 0x8973190e. Error writing file '%CSIDL_PROGRAM_FILES%\NServer\NServer.dll'. Error 0x80450001: (null)

    From where, I can generate the UUID?

    // ATLTutor.idl : IDL source for ATLTutor
    //
    
    // This file will be processed by the MIDL tool to
    // produce the type library (ATLTutor.tlb) and marshalling code.
    
    import "oaidl.idl";
    import "ocidl.idl";
    
    [
    	object,
    	uuid(3A450DD1-E910-4f7c-9C69-9836CF4DC196),
    	helpstring("IHello Interface"),
    	pointer_default(unique)
    ]
    interface IHello : IUnknown{
    	[helpstring("method Hello")] HRESULT Hello(void);
    };
    [
    	uuid(9A603241-3C36-4d38-9F3C-206A0211B1F0),
    	version(1.0),
    	helpstring("ATLTutor 1.0 Type Library")
    ]
    library ATLTutorLib
    {
    	importlib("stdole2.tlb");
    	interface IDocHostUIHandlerDispatch;
    	interface IAxWinAmbientDispatchEx;
    	[
    		uuid(71B3EECF-96A6-43d6-8636-A7AF32F625E8),
    		helpstring("Hello Class")
    	]
    	coclass Hello
    	{
    		[default] interface IHello;
    	};
    };

    uma shankar
    • Edited by Shanuma Monday, December 12, 2011 10:48 AM
    • Merged by lucy-liu Wednesday, December 14, 2011 7:09 AM duplicate thread
    Monday, December 12, 2011 10:24 AM
  • It is unclear why you think this has anything to do with your GUIDs.  They don't have to be specific values for COM to work, you can't have 'wrong' GUIDs, unless they aren't unique.

    >Deployment and/or registration failed with error: 0x8973190e. Error writing file '%CSIDL_PROGRAM_FILES%\NServer\NServer.dll'. Error 0x80450001: (null)

    This is indicative of a deployment or registration failure, as it says.  One possible reason is you are on Vista or later and aren't running VS as admin thus don't have permissions to write to Program Files. Or perhaps your dll has dependencies that aren't satisfied and when regsvr tries to register it it is failing.

    Ryan

    Monday, December 12, 2011 3:53 PM
  • I created the above IDL file programmatically.  I wrote code for this using VCCodeModel.

    The UUID's shown here are obtained from(Tools->CreateGUID). I manually copied the UUID's and gave it to my VCCode Model and generated

    this IDL file.

    It builds fine.  But the CoCreateInstance fails.......

     

    I am new to COM and Code Generation.  So, my questions might be unclear.......... Please Help..........


    uma shankar

    • Edited by Shanuma Monday, December 12, 2011 4:35 PM
    Monday, December 12, 2011 4:34 PM
  • What is the failure code from CoCreateInstance?  From the error you have above it seems the dll isn't being registered, which means CoCreateInstance would fail as the proper data isn't in the registry for it to know what dll the class factory lives in.  As I said before are you running VS as admin when loading your solution (that builds the COM dll) so that regsvr has access to write to the proper registry hive and the deployment step can write to %ProgramFiles%?

    Ryan

    • Marked as answer by Shanuma Tuesday, January 10, 2012 11:16 AM
    Monday, December 12, 2011 6:50 PM
  • CoCreateInstance fails with:  Error code 0X80040154.

    I am running VS as administrator.

     

    In the image, the problem is only with:  UUID for the Class

     


    uma shankar
    Monday, December 12, 2011 7:47 PM
  • That HRESULT is REGDB_E_CLASSNOTREG, that means the registration info for your class is not in the registry, it doesn't mean your GUID is 'wrong', it just isn't registered.  The failure you posted above is a failure to deploy/register, which means your code won't work until you get that figured out. 

    This really has nothing to do with Visual Studio extensibility, it is a COM registration/deployment issue, so this is probably the wrong forum.

    Ryan

    Monday, December 12, 2011 8:31 PM
  • Hi Shanuma,

    This is a duplicate thread with http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/2f021ec6-3f10-4e92-bc23-1227e6373e65 . I will merge them to keep in the same issue.

    Thank you for your understanding!

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, December 14, 2011 7:08 AM
  • Hi Shanuma,

    Ryan has pointed that this issue is caused by fail deploy/register. so if you still have any further concern about this issue, please write a new thread to a more suitable forum.

    If you have no idea which forum should post, you can goto Where is the Forum For…? For answer.

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 10, 2012 6:18 AM