I found the tool (VS2008->Tools-> ArcGIS Code Migration analyzer):
Not very helpful, why?
Because the tool assumed that I keep my reference Dlls in Program files\ArcGis\...
And I don't!
In my organization there are non GIS programmers and they don't have ArcEngine installed, so we keep the ESRI Dlls in a Libraries sub folder in the TFS.
That way the build server can build the project but not necessarily run it.
So the tool gave me the message of:
ArcGIS Code Migration analyzer run on 29/11/2010 at 14:22
--------------------------------------------------------------
Analyzing project: Company.GIS.Core.Esri.ConfigTests
No ESRI assembly references found. Project skipped for conversion.
-------------------------
So I had to manually change the Dlls (but that is ok since I needed to add them to the TFS).
Everything was build without errors but when testing all of the ESRI tests failed with:
System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {D9B4FA40-D6D9-11D1-AA81-00C04FA33A15} failed due to the following error: 80040111..
It failed on this line:
IWorkspaceFactory2 workspaceFactory = new SdeWorkspaceFactoryClass ();
I did a bit of Googling and found this post:
http://blogs.esri.com/Dev/blogs/arcgisdesktop/archive/2009/12/01/Migrating-to-Engine-9.4-and-using-the-VersionManager.aspx
So I have added the ESRI.ArcGIS.Version.dll to the libraries folder and the reference and added this code:
public class EsriInitilization
{
private static bool _isStarted = false ;
public static void Start()
{
if (!_isStarted)
{
if (!RuntimeManager .Bind(ProductCode .Server))
{
if (!RuntimeManager .Bind(ProductCode .Engine))
{
throw new ApplicationException (
"Unable to bind to ArcGIS license Server nor to Engine. " +
"Please check your licenses." );
}
}
_isStarted = true ;
}
}
}
What this does is tries to Bind the server license and if it fails it tries the engine license, it can be found here on the examples (for some reason ESRI didn't include what the return value of the Bind method in their help but are using it in their example… (I tried sending them an email asking for a fix to that but their mail address doesn't work…))
I later found out that the _isStarted is needed when you use Engine license since it seems calling the method more than once will go through both ifs and throw the ApplicationException exception (because the license is already taken).
And then I tested again.
This time I got a pop up:
The text:
VSTestHost.exe - Entry Point Not Found
The procedure entry point ?doctypeWhitespace@SAXParser@xercesc_2_7@@UAEXQB_WI@Z could not be located in the dynamic link library xerces-c_2_7.dll.
And for all the randomness in the files and text they are the same in three runs…
So debugging, and we did pass one checkpoint in our road, we now get the error in this line:
[Code for initializing the license]
return workspaceFactory.OpenFromString (sdeConnectionString, 0);
The xerces-c_2_7.dll is "designed to provide a way for a process to call a function that is not part of its executable code." (at least according to this).
So Googled again and found this forum.
The answer this time was uninstalling ArcSde 9.3.1 (I installed 10 because some of my tests are of deployment).
Why doesn't ESRI's Detect Conflict tool didn't uninstall this as well???
Some tests still didn't pass:
1. Tests that check the description of a ComException (it might have changed but not by much…) – I fixed those by hand.
2. One test that renames a layer that has polyline data. Right now it's in a piece of code we don't really use (for easier DB deployment). The really messed up thing is that it works with polygon and point data…
The error that I got was:
System.Runtime.InteropServices.COMException: The number of points is less than required for feature.
(It's has a polyline with 4 points, and the polyline is saved and read from the DB just fine).
I later fixed the problem I will post in Rename Polyline layer
And then I changed the DB to a DB running SDE 10.
All was well until I tried to generate my base classes using MyGeneration code generation tool. It seems that SDE changed the DateTime type that they use to datetime2 and MyGeneration didn't know that type.
I fixed that quit easily.
Another change in the DB is that SDE tables (without a shape) no longer have OBJECTID.
Be Warned if you use that field as an identification column!
Build Warning after the changes:
- Using the reference ESRI.ArcGIS.ADF like in ComReleaser is obsolete use instead ESRI.ArcGIS.ADF.Connection.Local – only needed to change the reference
When testing the application with only ArcEngine License we found out that you need ArcGis Server license in order to use ArcObjects within a web service / WCF service. Be warned!!!
del.icio.us Tags:
ESRI,
Upgrading,
Migrating,
ArcGIS 9.3.1,
ArcGIS 10,
ArcSDE,
OBJECTID,
xerces-c_2_7.dll,
ComReleaser,
COMException,
RuntimeManager,
ArcEngine,
ArcObjects
IceRocket Tags:
ESRI,
Upgrading,
Migrating,
ArcGIS 9.3.1,
ArcGIS 10,
ArcSDE,
OBJECTID,
xerces-c_2_7.dll,
ComReleaser,
COMException,
RuntimeManager,
ArcEngine,
ArcObjects