tags:

views:

1989

answers:

3

I've created a batch job that running in 32bit mode as it using 32bit COM objectes, this need to connect to SharePoint to make updates to list. It works in my development environment as it is full 32bit. But in my test and prodution environment we use 64bit SharePoint and this is what I get from SPSite:

System.IO.FileNotFoundException: 
  The Web application at http://<my sp host>/ could not be found. 
  Verify that you have typed the URL correctly. 
  If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri req...

this is what I do

        using (SPSite site = new SPSite(_url))
        {
            using (SPWeb web = site.OpenWeb())
            {
                try
                {
                    SPList list = web.Lists[new Guid(_listID)];
                    SPListItem item = list.GetItemById(id);
                    item[field] = value;
                    item.SystemUpdate(false);
                }
                catch (Exception x)
                {
                    log.Error(x);
                }
            }
        }
+1  A: 

I don't think this is a 32/64bit issue as I am in the same situation as far as developing on 32bit and deploying to 64bit. (Actually, we are running a 32bit and 64bit WFE'S)

Since the exception is being thrown from the SPSite constructor, I would investigate further, as to whether the machine you are running you code on (the SP box) actually recognizes that URL.

AdamBT
If I compile the application as a 64bit and just trying the SPSite code all works great. So it has something to do with 64bit SharePoint not allowing calls from 32bit.I can use the webservice for list update but it always create a new version of the listitem and I need the item to have same version
walming
+1  A: 

You simply need to run your batch job in a 64-bit process. The problem is that SharePoint has many COM objects under the hood which are compiled for 64-bit in your test and production environment. The SPSite and SPWeb objects actually wrap the COM objects which is why they fail in your 32-bit process.

One work-around could be to interact with SharePoint through its Web Services instead of the object model.

Lars Fastrup
I need it to run in 32bit mode as I use other COM objecte that only work in 32bit mode this is not an option.Using SharePoint webservice dont work as I need to do a SystemUpdate so the item dont get a new version.
walming
I think we got a catch 22 here as the 64-bit SharePoint COM objects beneath the managed SharePoint API simply wont work in 32bit mode. It is more work but you could consider installing your own Web service with support for SystemUpdate on list items.
Lars Fastrup
A: 

Hi Walm,

Have u solved this problem. please tell me how to solve this.I am getting same problem

thanks.