ThinkGeo.com    |     Documentation    |     Premium Support

File Not Found on Proj lookup

Hi,

I have a user that got an error when trying to export to shapefile. When I looked at the error, it points to a directory that should have 11 files in it, but only has 2 on his computer. I’ve already noted that this directory is created by something on your side, so question is where are the other 9 files?

Here’s the error. The two files that did get copied are gdal_datum.csv and version.txt.

System.IO.FileNotFoundException: To use EPSG ID for conversion, please copy MapSuitePrjHelper folder to your C:\Users<USERNAME>\AppData\Local\Temp\MapSuite\PersistentCaches\mapsuite\proj-csv folder —> System.IO.FileNotFoundException: Can not find the file associate with the parameter specified.

I have run this successfully on several other computers and they all copy across the 11 files needed.

Any ideas?

Thanks,
Damian

Thanks Damian,
If you using the Gdal related package such as ThinkGeo.Ecw. The gdaldata folder should auto copy to the output folder(bin\Debug). For some reason the visual studio may not able to copy to the output folder. We could manually copy the folder to the target folder or remove all thinkgeo related package and re-add the nugget package.

Thanks

Frank

Hi Frank,

This is for a user that has installed from the distribution, not for a build I am running through VS.

Regards,
Damian

Thanks Damian,
When we create the distribution for the end user we need make sure we have the gdal related files ready in the delivery folder. Ideally these files should auto copied to the target folder when we compile the project. If not we could manually copy to there.

Thanks

Frank

Hi Frank,

The files are in the distribution (installer). I’m saying that we have (currently) just one user that this has installed our software and the files did not all copy to the target folder.

Do you have any cases at all that sound like this?

Regards,
Damian

Damian,
It is strange. We don’t see this issue before. The same installer just one user has this issue.

Thanks

Frank

Yes, that’s correct.

Can you please explain what is going on with this PersistentCaches folder? I notice that this directory no longer exists on my computer, so seems to be periodically removed by some process you guys are doing.

Regards,
Damian

Thanks Damian,
In V12 we are using the .Net Core build in API to get the temp folder which is Path.GetTempPath()
So the folder will change to C:\Users\[Username]\AppData\Local\Temp\

Thanks

Frank

Hi Frank,

Is it same for v10?

Seems inobtrusive. Must be some problem with users computer.

Regards,
Damian

Thanks Damian,
No. The V10 still using the PersistentCaches folder.

Thanks

Frank

Hi Frank,

Looks like we need to explore this further. I now have another user that the PersistentCaches directory is not being created. I suspect something is blocking the copy or perhaps some kind of permission issue.

The error happens when the user tries to write a shapefile if that helps for knowing what libraries are needing the files. Nothing to do with ECW images as you mentioned early on in the thread.

Thanks,
Damian

Thanks Damian,
If we create the shape file. Here some code try to create some files.
if (needCreated)
{
string tempFolder = PclSystem.Environment.GetTemporaryFolder();
if (!PclSystem.Directory.Exists(tempFolder)) PclSystem.Directory.CreateDirectory(tempFolder);
string tempDbfPath = PclSystem.Path.Combine(tempFolder, PclSystem.Path.GetFileName(dBaseEngine.PathFilename));
Collection newColumns = GetNewDbfColumns(filteredEditColumns);
try
{
GeoDbf.CreateDbfFile(tempDbfPath, newColumns, OverwriteMode.Overwrite, this.dBaseEngine.Encoding);

Here is the code to get the temp folder

  internal partial class EnvironmentProvider
    {
        public string SystemDirectory
        {
            get
            {
                return Environment.SystemDirectory;
            }
        }

        public string GetEnvironmentVariable(string variable)
        {
            return Environment.GetEnvironmentVariable(variable);
        }

        public string GetTemporaryFolder(params string[] relativePaths)
        {
            string tempPath = string.Empty;
            if (PclSystem.Current.Platform == PclPlatform.Linux) return PclSystem.Path.Combine(new[] { "/var/tmp" }.Concat(relativePaths).ToArray());

            if (string.IsNullOrEmpty(tempPath)) tempPath = PclSystem.Environment.GetEnvironmentVariable("Temp");
            if (string.IsNullOrEmpty(tempPath)) tempPath = PclSystem.Environment.GetEnvironmentVariable("Tmp");

            tempPath = string.IsNullOrEmpty(tempPath) ? @"c:/MapSuiteTemp" : PclSystem.Path.Combine(tempPath, "MapSuite");
            tempPath = PclSystem.Path.Combine(tempPath, "PersistentCaches");

            if (relativePaths != null)
            {
                tempPath = PclSystem.Path.Combine(tempPath, string.Join(PclSystem.Path.DirectorySeparatorChar.ToString(), relativePaths));
            }

            return tempPath;
        }

so here is the priority for the temp folder

GetEnvironmentVariable(“Temp”) -> GetEnvironmentVariable(“Tmp”) -> “C:\MapSuiteTemp”

We may need check if the user deleted the temp/tmp EnvironmentVariable. Finally it has to try to create folder C:\MapSuiteTemp. It may not allow user create folder under C drive.

Do you have any error message we could find out where the application try to find/create the file?

Thanks

Frank

Hi Frank,

I’m having some issues with your code to create temp files (first part).

What is the dBaseEngine object? It isn’t in the provided code.
What is the Collection type? It is not installed with BareBones v10.
What is GetNewDbfColumns function? It is not installed with BareBones v10.
What is the filteredEditColumns variable? It isn’t in the provided code.

image

Thanks,
Damian

Hi Frank,

Some more info for you.

  1. We were able to circumvent the error by copying the files from a good computer and creating the PersistentCache directory on a users machine with the problem.
  2. After that, we deleted PersistentCache on the same users machine and then tried to export a shape file again. This time, the PersistentCache files were created!

I’ve no idea if this will be the case every time, but there must be something odd in your code that creates these files for it to work sometimes and not others. If it were permissions or missing environmental variables, the failure would always occur.

Regards,
Damian

Thanks Damian,
Yes. it is very strange. Just copy the folder to there and delete it. I am keep looking into more detail. I will update you once I get any progress.

Thanks

Frank

Hi Frank,

Now, this has happened on my machine, so this is definitely not specific to one type of machine. Here’s the full stack. Let me know what can be done to troubleshoot further.

BTW: Did you miss my questions on Apr 13. I never got a reply.

System.IO.FileNotFoundException
HResult=0x80070002
Message=To use EPSG ID for conversion, please copy MapSuitePrjHelper folder to your C:\Users\damian\AppData\Local\Temp\MapSuite\PersistentCaches\mapsuite\proj-csv folder
Source=ThinkGeo.MapSuite
StackTrace:
at ERg=.sCA=.siA=(String proj4, IFormatProvider provider)
at ThinkGeo.MapSuite.Shapes.Proj4Projection.ConvertEpsgToPrj(Int32 srid)
at SurveyDesign.Map.ExportLayer(Layer layer, String fileName) in C:\Users\damian\OneDrive - acteq.net\Visual Studio Projects\Projects\TesserACT\SurveyDesign\Map.cs:line 11471
at SurveyDesign.Map.tsmi_Export_Click(Object sender, EventArgs e) in C:\Users\damian\OneDrive - acteq.net\Visual Studio Projects\Projects\TesserACT\SurveyDesign\Map.cs:line 11506
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at TesserACT.Program.Main() in C:\Users\damian\OneDrive - acteq.net\Visual Studio Projects\Projects\TesserACT\TesserACT\Program.cs:line 18

This exception was originally thrown at this call stack:
ERg=.KiE=.dCE=(string, int)
ERg=.KiE=.cyE=(int, System.IFormatProvider)
ERg=.KiE=.ciE=(int, System.IFormatProvider)
ERg=.KiE=.2iE=(string)
ERg=.sCA=.siA=(string, System.IFormatProvider)

Inner Exception 1:
FileNotFoundException: Cannot find epsg.wkt under Map Suite Prj Helper Folder.

A bit more detail. Seems the directory exists on my machine (other users it did not), but some of the files are missing as shown here.

Regards,
Damian

Damain,
Could you send me more code in the
tsmi_Export_Click

We should be able to fix it if this can reproduce on our machine.

Thanks

Frank

Frank,

This is the code that is failing.

string projString = Proj4Projection.ConvertEpsgToPrj(EPSG#);

Regards,
Damian

Thanks Damian,
I am trying with code you using. Still can not reproduce this one. I attached you my demo project I am using. HelloWorldSample.zip (384.9 KB)

  1. Could you delete the old proj-csv folder on the machine with the problem. From the screen shot. The file was created at 2015. I guess they were created by old version of mapsuite, at that time we don’t put the proj-csv to there. Base on the code I read

    bool needUpdate = !isProjCsvFolderExist || !PclSystem.File.Exists(versionPathFilename);

We will re-copy the files if the proj-csv folder not there or the version file not there. Base on your screen shot. It won’t match the criteria to copy the new files. So I think delete the old files will let mapsuite re-copy all new files to the folder.

  1. If still not work. We may need some work around. such as: Force copy these files to the C:\Users[UserName]\AppData\Local\Temp\MapSuite\PersistentCaches\mapsuite\proj-csv folder right after the application start.

Thanks

Frank