ThinkGeo.com    |     Documentation    |     Premium Support

Error message : DataReader.GetFieldType (13) returned null

Hi,

We have a message error like this :
Message : DataReader.GetFieldType(13) a retourné la valeur null.
Exception type : System.InvalidOperationException
Failed method : ThinkGeo.MapSuite.Wpf.Tile.DrawException
Problem Id : System.InvalidOperationException at ThinkGeo.MapSuite.Wpf.Tile.DrawException
Assembly : ThinkGeo.MapSuite.Wpf, Version=10.0.0.0, Culture=neutral, PublicKeyToken=0828af5241fb4207

StackTrace :
System.InvalidOperationException:
at ThinkGeo.MapSuite.Wpf.Tile.DrawException (ThinkGeo.MapSuite.Wpf, Version=10.0.0.0, Culture=neutral, PublicKeyToken=0828af5241fb4207)
at ThinkGeo.MapSuite.Wpf.Tile.Draw (ThinkGeo.MapSuite.Wpf, Version=10.0.0.0, Culture=neutral, PublicKeyToken=0828af5241fb4207)
at ThinkGeo.MapSuite.Wpf.LayerOverlay.DrawTileCore (ThinkGeo.MapSuite.Wpf, Version=10.0.0.0, Culture=neutral, PublicKeyToken=0828af5241fb4207)
at ThinkGeo.MapSuite.Wpf.TileOverlay.DrawTile (ThinkGeo.MapSuite.Wpf, Version=10.0.0.0, Culture=neutral, PublicKeyToken=0828af5241fb4207)
at ThinkGeo.MapSuite.Wpf.TileOverlay.DrawCore (ThinkGeo.MapSuite.Wpf, Version=10.0.0.0, Culture=neutral, PublicKeyToken=0828af5241fb4207)
at ThinkGeo.MapSuite.Wpf.Overlay.Draw (ThinkGeo.MapSuite.Wpf, Version=10.0.0.0, Culture=neutral, PublicKeyToken=0828af5241fb4207)

This error occurs when instantiating a new MsSql2008FeatureLayer layer.
This error is related to the particular case of an MsSql2008FeatureLayer corresponding to a tablename = a view.
Ex : layer.TableName = coucheSql.Table; (layerSql.Table is the name of a view in our database)

In our project, we instantiate other layers of MsSql2008FeatureLayer type which is not a problem, but these layers rely on sql tables and not views
Note that DataReader.GetFieldType (13) is the Geometry column of the view.
Have you ever encountered this kind of problem ?

The difficulty is that this error message only appears on some PCs and on others, it works fine ;-(

Thanks
Regards.

Steph.

Hi Steph,

We hadn’t met that before, but I search it and found that’s maybe related with the datatype change for new SQL Server.

And the solution in post mentioned you can did this in your project:

Reference the Microsoft.SQLServer.Types dll from the project and for the reference set it as “Copy Local” in the properties of the reference.

Maybe you can find the dll here: C:\Program Files (x86)\Microsoft SQL Server\110\Shared\Microsoft.SqlServer.Types.dll

And here is the topic about it:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/eae17407-2910-455c-92eb-8c28e5dabbc5/datareadergetfieldtype-returned-null?forum=sqlnetfx

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,

Thanks for your help.

We had already referenced this dlls in our project.
What is strange is that this error appears only on some PCs, on other PCs there is no problem ;-(
On PCs that have this problem, this only appears if the MssqlFeatureLayer layer reads a view ie layer.TableName is the name of a view of the sql database.
If MssqlFeatureLayer is linked to a sql table, there is no problem on these pcs.
Have you already reproduced this problem ?

Thanks.

Regards.

Hi Steph,

I will create a VM with SqlServer to see whether it works the same with view and table.

We hadn’t found the difference when we test it before.

I will update this post after test.

Regards,

Ethan

Hi Steph,

We still hadn’t reproduced it, we test it in the new environment and it looks View works the same like Table.

So could you please upload a really simple sample which can reproduce it? Maybe you can try to don’t use map, only use the SqlClient class to try to reproduce it.

Regards,

Ethan

Hi Ethan,

I have prepared a small project with a database that presents the problem on some of our client computers.
Below, the description of the differents elements are :

  1. ThinkgeoProblemView is the database to restore. This is the view (dbo.vw_AnalyseCarto) that raises concern. The dbo.cartographie table works well.
  2. 0190218_TicketViewAnalyseTerre.zip is the project that reproduces the problem
    a) The ListeCouchesACharger.xml file in the project lists the layers to display in the map. In order for the project to work, you just need to specify the name of your sql instance in this file.
    This is the view (dbo.vw_AnalyseCarto) that is currently enabled in the file ListeCouchesACharger.xml. You can comment on this view and enable the dbo.cartographie table if you wish.
    b) cf. Screen shot (ListeCouchesACharger_ActiveVIew.JPG ; ListeCouchesACharger_ActiveTable.JPG)
    c) The screen shot Screenshot.jpg is what you should see if project start well
  3. file.txt generated is the log file in the repository debug
  4. I added some files for you to see the environment of our test machines (system_OK.txt; system_PASOK.txt; PC_PASOK.jpg; PC_OK.JPG)
    If the file is suffixed PASOK, it means that the project does not work on these machines
    If the file is suffixed OK, it means that the project works on these machines

Note that by continuing to look at the problem, one of the common points of machines that do not work is the version of SQL 12.0.5000.0, but I do not know if the problem can come from there

Thanks for your help.

Regards.

Steph.2019103_Thinkgeo.zip (2.9 MB)

Hi Steph,

Thanks for your information, we will try to reproduce it first.

Any question or update I will let you know.

Regards,

Ethan

Hi Steph,

Our developer build a new test environment for it, but it looks we had been blocked when try to restore your backup file.

You can see, when we choose the bak file, the inner database cannot be parse correct, and we cannot go to next step.

The MSSQL Server Management Studio is 2014, and the database engine is SQL Server 10.50.4042.

Could you please check the bak file and update it? Or if we go incorrect way to restore it please let us know.

Regards,

Ethan

Hi Ethan,

The problem comes from the difference of version between our 2 DBMS (you are in 2008 R2, I am in 2014).
I made an alter database so that it can be compatible with 2008 R2 in this new Backup.
Normally you should be able to restore it.
Thanks

Regards.

ThinkgeoProblemViewCompatible.zip (591.0 KB)

Hi Steph,

Thanks for your update, but it looks the error still there.

In fact I install the SQLServer in another machine today and restore also don’t works, I am not so familiar with database so I hadn’t found where is the problem. If the restore backup don’t works, do you think it’s possible to export the script to build tables, and another script to import some data in it? And if it don’t need so many items to reproduce the problem, you can just export part of the data for example 100 items in your script.

Regards,

Ethan

Hi Ethan,
The version of your Sql server is still database engine is SQL Server 10.50.4042. ?
If so, can you pick a version more recent as 12.0.5000 for example.
you can choose a Sql server express, it’s free. (https://www.microsoft.com/en-us/download/details.aspx?id=53167)

regards.

Steph

Hi Steph,

Thanks for your suggestion, I will try to upgrade the version and try it again.

Regards,

Ethan

Hi Steph,

Because it will be weekend now, I want to update the status today.

The good news is it looks restore works after upgrade version. But upgrade SqlServer also introduce some strange problems in our test environment, the tables cannot be opened now. Uninstall old versions don’t solve it. (I think MS should update their uninstall utility, the latest version I found do some change, even repair cannot make it works).

But please don’t worry about it. I will recreated an environment with SqlServer 2014 first and try to reproduce your problem after that.

Regards,

Ethan

Hi Steph,

Sorry for the late reply.

Uninstall old version of SQL Server make the environment met strange problems, I still cannot solve it and because we cannot reinstall OS now. So we bought a cloud machine in AWS for this problem, then we restore the backup and try to reproduce your problem there.

But it looks the application run well:

It looks the two buttons “Extend” and “Zoom to jp2 raster leak memory” don’t have related events, do you thinks it’s missed in the project? If you have a step to reproduce it that should be helpful.

Regards,

Ethan

Hi Ethan,

Thanks for your response.
The problem comes as soon as the project is opened.
The 2 buttons are a relic of an old test project (I could have deleted them).
It’s weird that you have not managed to reproduce the problem.
You have installed version 12.0.5000 of sql?
What kind of Collate Sql do you have for your Sql Server?
in our projects, we use Latin1_General_CI_AS. Is it the same for you? (Maybe the difference in behavior can come from there?)

You can see all Collate Sql listed by SQL with this query :

SELECT name, description
FROM fn_helpcollations()

The name of the collate that we use is Latin1_General_CI_AS

SELECT name, description
FROM fn_helpcollations()
where name like ‘Latin1_General_CI_AS’

Thanks
Regards.

Steph.

Hi Steph,

Does 12.0.5000 is necessary? It looks the AWS installed version is the latest version, it’s number is 14.0.1000.

If 12.0.5000 is necessary I will try to reinstall it.

And the “Server Collation” of database instance is “SQL_Latin1_General_CP1_CI_AS”:

But it’s “Latin1_General_CI_AS” for target database “ProblemView”:

Do you think it have problem here?

Regards,

Ethan

Hi Ethan,

Thanks for your response.

PCs that have this problem have this common point of having version 12.0.5000, so this can be a track.
For the Sql server collation, I specified the one that we install on our posts so that you have as much information as possible, and thus have the same working environments.
It is possible de change the server collation after insatllation if you want (https://www.mssqltips.com/sqlservertip/3519/changing-sql-server-collation-after-installation/)

But I think the problem is the version of sql server 12.0.5000.

Thanks.

Regards.

Steph.

Hi Steph.

Today I uninstall the 2017, then reinstall 2014 and upgrade it to sp2 (that’s 12.0.5000). And when I reinstall the 2014, I choose the collation and set it equal Latin1_General_CI_AS.

But it looks the test result is still OK without exception.

Do you think it still have anything we missed about the environment? If you hadn’t found anything, I think I can sent you a test connection string, and you can see whether your code can reproduce it with my database(If it can reproduce that with your database).

Regards,

Ethan

Hi Ethan,

Thanks for your test.

I just want to do a last test on our side, but I have to activate this new application on a PC’s client (currently, I have a license no activate that appears)

Is it possible to activate as many applications as we want with our WPF thinkgeo license? (Currently, we have only one app activated with Thinkgeo.) ? (https://wiki.thinkgeo.com/wiki/map_suite_runtime_license_guide_for_desktop)

Thanks.

Regards.

Steph.

Hi Steph,

If you are directly run your application there, you can build the run time license just follow the guide in our wiki, then put the license file in the same folder of your execute file. Then it can works in your new machine.

If you want to debug it there, please upgrade all your packages into the latest version, then deactivate your license from your currently machine and then login the same account and activate it in the new machine.

Any question please let us know.

Regards,

Ethan