Create report in class library

Stimulsoft Reports.NET discussion
ggrote
Posts: 6
Joined: Mon Sep 08, 2014 9:55 am

Re: Create report in class library

Post by ggrote »

Ok, I spent some time searching for the problem and digged deeper into your sourcecode ( Sorry for that! 8-) ) to find a solution for our project, where the customer wants to use your reporting library.

Just another thing I found out:
If you set the output type of ProIT's ClassLibraryWithReportGen to "Windows-Application" everything works. But that can not be the solution!

It looks like there is something wrong with getting the Localization path from the registry on 64bit systems.

This should be changed

Code: Select all

          RegistryKey registryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("\\SOFTWARE\\Stimulsoft\\Stimulsoft Reports");
to this

Code: Select all

          RegistryKey registryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Stimulsoft\\Stimulsoft Reports");
to get it working on 32bit machines.

And the phkResult in this function

Code: Select all

internal static string GetRegKey64(UIntPtr inHive, string inKeyName, Registry.RegSAM in32or64key, string inPropertyName)
      {
        int phkResult = 0;
        try
        {
          if (0 != (int) Registry.RegistryWOW6432.RegOpenKeyEx(Registry.RegHive.HKEY_LOCAL_MACHINE, inKeyName, 0U, (int) (Registry.RegSAM.QueryValue | in32or64key), out phkResult))
            return (string) null;
should be changed to use an uint according to http://www.pinvoke.net/default.aspx/adv ... gopenkeyex => - Changed IntPtr to UIntPtr: When invoking with IntPtr for the handles, you will run into an Overflow. UIntPtr is the right choice if you wish this to work correctly on 32 and 64 bit platforms.

And in your latest version which is compiled against .Net 4.0 you should use the new framework methods to get registry keys:

Code: Select all

RegistryKey registryKey;
if (Environment.Is64BitOperatingSystem == true)
{
    registryKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
}
else
{
    registryKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
}
I don't know why there is a difference between Library-Class and Windows-Application and why it works without debugger. This is your task to find it out :D
ggrote
Posts: 6
Joined: Mon Sep 08, 2014 9:55 am

Re: Create report in class library

Post by ggrote »

ProIT wrote:It worked only a few times. After I upgraded to the latest version (because of another bug) I did get the old error. You know, time is money and I can't take the risk, that our solutions is sometimes working and sometimes not... Sorry...:(
Do you have a recommendation for another software that works?
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Re: Create report in class library

Post by Jan »

Hello,

Thank you for your investigation and sorry for troubles with our product!

We have fixed this bug. You can get fixed version of our software in next prerelease build (which will be available at 12 Sep 2014.
Also you can send request to our support@stimulsoft.com Email with url to this topic and we can send you fixed version shortly.

Thank you.
Post Reply