System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Stimulsoft Reports.NET discussion
Post Reply
SpragueR
Posts: 5
Joined: Mon Jun 28, 2021 3:54 am

System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Post by SpragueR »

This occurs when dynamically loading an assembly that references the Stimulsoft assemblies (version 2021.3.4.0) and the Stimulsoft assemblies are in turn automatically loaded from the same folder as the dynamically loaded assembly.

A 7-Zipped sample project (VS 2019) that reproduces this problem can be found here.
https://drive.google.com/file/d/1gYtHYT ... sp=sharing

Type = System.NotSupportedException
Message = TypeConverter cannot convert from System.String.
Source = System
TargetSite = System.Exception GetConvertFromException(System.Object)
StackTrace = at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at Stimulsoft.Base.StiObjectStringConverter.StringToObject(String str, Type type) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Base\StiObjectStringConverter.cs:line 97
at Stimulsoft.Report.StiReportObjectStringConverter.StringToObject2(String str, Type type) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report\StiReportObjectStringConverter.cs:line 296
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Base\Serializing\StiSerializing.cs:line 1059
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Base\Serializing\StiSerializing.cs:line 958
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Base\Serializing\StiSerializing.cs:line 958
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Base\Serializing\StiSerializing.cs:line 958
at Stimulsoft.Base.Serializing.StiSerializing.Deserialize(Object obj, Stream stream, String application) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Base\Serializing\StiSerializing.cs:line 1218
at Stimulsoft.Report.SaveLoad.StiXmlReportSLService.Load(StiReport report, Stream stream) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report\SaveLoad\StiXmlReportSLService.cs:line 97
at Stimulsoft.Report.StiReport.Load(StiReportSLService service, Stream stream) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report\StiReport.SaveLoad.cs:line 1607
at Stimulsoft.Report.StiReport.Load(Stream stream) in D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report\StiReport.SaveLoad.cs:line 1471
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Post by Lech Kulikowski »

Hello,

Could not load file or assembly 'file:...StimulsoftReports\bin\Debug\CompanyABC.StimulsoftReports.dll' or one of its dependencies. The system cannot find the file specified.'

Thank you.
SpragueR
Posts: 5
Joined: Mon Jun 28, 2021 3:54 am

Re: System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Post by SpragueR »

Hi Lech,

Ensure that the StimulsoftReports project is built before running the WindowsFormsApp1 project; Build -> Build Solution.

As the WindowsFormsApp1 project does not reference the StimulsoftReports project directly (in button1_Click it loads the assembly dynamically), VS will not rebuild the StimulsoftReports project before running the WindowsFormsApp1 project.

Then read the comments in button2_Click to uncomment two lines of code and run the “same” logic but not loading the assembly dynamically.
SpragueR
Posts: 5
Joined: Mon Jun 28, 2021 3:54 am

Re: System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Post by SpragueR »

Hi Lech,

In the forums others have reported this same exception previously but you have never been able to reproduce the problem in your test environment.
I believe the project I provided will allow you to reproduce this problem.
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
SpragueR
Posts: 5
Joined: Mon Jun 28, 2021 3:54 am

Re: System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Post by SpragueR »

Noted. Thanks for the update.
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Post by Lech Kulikowski »

Hello,

Unfortunately, we can not fix this.
We use the TypeConverter functionality in many places, e.g. loading/saving reports with it. Due to the peculiarities of Net Framework implementation, this does not work correctly if assemblies are not loaded explicitly or from the application folder. This is a feature of NetFramework, there is nothing we can do. Sorry.

Thank you.
SpragueR
Posts: 5
Joined: Mon Jun 28, 2021 3:54 am

Re: System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Post by SpragueR »

Hi Lech,

Noted. Thanks for the quick response.
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Re: System.NotSupportedException. Message = TypeConverter cannot convert from System.String

Post by Andrew »

Hello,

You are welcome!
Post Reply