[Solved] How to compile markup and create the resource dll in non VS IDE

Jun 20, 2010 at 4:21 AM

Hi,

I develop winfrom app in the Eclipse IDE where I can add the RibbonLib dll as local assembly. My question how i can compile markup and create the resource dll in non VS IDE as shown step 3 in your Part 3 documentation. Are there any commands to achieve that from the SDK.

Thanks

Coordinator
Jun 23, 2010 at 3:35 PM

To compile the ribbon markup xml into a dll you need the following steps:

XML -> RC -> RES -> DLL

The three transitions are done using the commands which I mention in the part 3 blog post:

"%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0\Bin\UICC.exe" "$(ProjectDir)RibbonMarkup.xml" "$(ProjectDir)RibbonMarkup.bml" /res:"$(ProjectDir)RibbonMarkup.rc"

"%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0\Bin\rc.exe" /v "$(ProjectDir)RibbonMarkup.rc"

cmd /c "("$(DevEnvDir)..\..\VC\bin\vcvars32.bat") && ("$(DevEnvDir)..\..\VC\bin\link.exe" /VERBOSE /NOENTRY /DLL /OUT:"$(ProjectDir)$(OutDir)$(TargetName).ribbon.dll" "$(ProjectDir)RibbonMarkup.res")"

The first two utilities come with the Windows 7 SDK.

The link.exe is just the visual C++ linker, that knows how to create a DLL with nothing but resources from and RES file.
I'm not familiar with eclipse environment, but I'm sure this can be done somehow. Otherwise you can try to get the link.exe file, I would expect it to be available on the web.

Hope this helps,
Arik Poznanski.

 

Jun 25, 2010 at 12:37 PM

Thanks Arik,

How do you interpret "$(OutDir)$(TargetName).ribbon.dll"? I guess ribbon.dll is the one I reference to your library but not to be created by the C++ linker, am i correct?

Regards

Kevin

Coordinator
Jun 25, 2010 at 3:37 PM

OK, I think I understand the confusion.

First there is a Ribbon.Dll which is my wrapper library you should reference to have any ribbon support.

Another DLL is the actual ribbon definition for your application.
You write is as an XML file, also known as RibbonMarkup.xml and then compile it with the following commands:

uicc.exe RibbonMarkup.xml RibbonMarkup.bml /res:RibbonMarkup.rc

This takes the input file RibbonMarkup.xml and generates two files, RibbonMarkup.bml which is a compact binary representation of the ribbon markup, and RibbonMarkup.rc which is a resource definition file, which defines the binary file (RibbonMarkup.bml) as a resource.

rc.exe /v RibbonMarkup.rc

This takes the input RibbonMarkup.rc and generates a compiled resource, that is, a RibbonMarkup.res file.

Finally, we create a native DLL which contains only these resources:

link.exe /VERBOSE /NOENTRY /DLL /OUT:MyApplication.ribbon.dll RibbonMarkup.res

This takes the input file RibbonMarkup.res and generates a new dll named MyApplication.ribbon.dll (not to be confused with the managed Ribbon.dll).

Hope this clarify the process,

Arik Poznanski 

Jun 27, 2010 at 8:25 AM

Thanks Arik, that's exactly what i was looking for.

Regards

Jun 28, 2010 at 12:27 PM
Edited Jun 28, 2010 at 12:30 PM

Hi Arik,

I think I am still having problems with the resource dll. In your VS .Net examples, the resource dll is created under the bin\debug directory (i guess this is what the $(OutDir) points to); I don't have the same structure in my Eclipse example, everything is put under the project directory, i.e c:\workspace\projects\myRibbon, so the resource dll I created is myRibbon.ribbon.dll under the project dir.

I am not sure if your wrapper find the .res file and the resource dll correct, when I called myRibbon:InitFramework(this-object) (myRibbon is an instance of RibbonLib.Ribbon, this-object is the form class, that implements the RibbonLib.IRibbonForm interface in my Eclipse example), I got "System.NullReferenceException: Object reference not set to an instance of an object." error.

I realised there are other overloaded InitFramework methods, so I tried myRibbon:InitFramework(this-object, "RibbonMarkup.res", "myRibbon.ribbon.dll"), but I got "System.runtime.interopservices.COMException: error HRESULT_FAIL has been returned from a call to a COM component." error; the .Net stack Trace gave me this:
-->   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at RibbonLib.Ribbon.InitFramework(IRibbonForm form, String resourceName, IntPtr hInstance)
   at RibbonLib.Ribbon.InitFramework(IRibbonForm form, String resourceName, String ribbonDllName)

Do you think I still miss anything else? the RibbonMarkup.xml, .rc, .res and .bml files were all created under the project directory.

Thank you very much

Ruan

Coordinator
Jun 29, 2010 at 1:06 PM

Try something like:

myRibbon.InitFramework(form, "APPLICATION_RIBBON", "yourApplication.ribbon.dll");

The first parameter is the IRibbonForm, which your form should implement.

the second parameter is what you set when you use the UICC, it is the native resource name in the dll.
If you don't change it the default is "APPLICATION_RIBBON".

The third parameter is the ribbon dll name that has the ribbon resources.

 
Jun 30, 2010 at 2:40 AM

Thanks Arik,

That's awesome, myRibbon.InitFramework(This-object, "APPLICATION_RIBBON", "myRibbon.ribbon.dll") worked!

One last question for this thread, can I give the .xml a different name, such as myRibbonDef.xml and generate the resource dll with a different name too, such as myribbon.newribbon.dll? and then I just pass the correct name to InitFramework method like above.

Once again, Thank you very much indeed!

 

Coordinator
Jun 30, 2010 at 6:17 AM

Of course you can change both the xml and dll file names.

Good luck.
Arik Poznanski.