Xerratus
Happily stressed out, since 1974


 
Friday, March 24, 2006
<< Guid WTF... How NOT to create a new guid
Nova Ice's fourth win in a row at Portland Meadows >>

Problem:
Error in Visual Studio 2005
Invalid access to memory location. (Exception from HRESULT: 0x800703E6). File: web.config. Line: 86

Line 86 of the web.config file:
<add assembly="Microsoft.SqlServer.Replication, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>

Explanation:
First off, why is "Replication" being referenced by the web project in the first place?

The project I'm working on is quite complex with about 12 projects within the web solution.  Of these projects, a database project exists which utilizes replication.  While the web project does not access this project directly it does access it indirectly thru a business logic layer project which references a data access layer project which references the database project.  

With that said, when I compiled, Visual Studio automatically added <add assembly="Microsoft.SqlServer.Replication, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/> to the web.config file which in turn thru the error Invalid access to memory location. (Exception from HRESULT: 0x800703E6). File: web.config. Line: 86.  

There is no way around it.  Even when I strip out line 86, Visual Studio just adds it right back.  What's worse is that the web.config file in our web project is under source control.  So every time we compiled the web solution, Visual Studio would prompt to check out the web.config.  For a while, my team and I would just ignore the prompt and NOT check out the file (stripped of line 86 of course) and all would be fine.  But just recently, I put it back because the prompting was just too much throughout a normal work day and set out to fix this once and for all.

Solution:
Quite honestly, I don't know if this is a solution or more of a work around because I think the problem is truly a Visual Studio bug that needs to be fixed.  

With that said, here’s the work around:
First, in the database project (the project that is actually referencing the replication) right click the references in question and select "properties" and set "Copy Local" = True.  In my case, the files in question are:

Microsoft.SqlServer.ConnectionInfo
Microsoft.SqlServer.Rmo

Now compile the database project ONLY.  Once this is complete, go to the bin directory of this project and you'll see the following dlls:

Microsoft.SqlServer.BatchParser.dll
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.Replication.dll
Microsoft.SqlServer.Rmo.dll

Select and copy these.

Now, navigate to the web directory Bin folder and Paste the copied files there.

Side note: If, like me, you are using source control you can add these files to Visual Studio THEN right-click each file and select "Exclude From Project".  This will simply create a file of the exact name suffixed with the .exclude extension.  Simply, this will allow the solution to be compiled without prompting you to check out the newly added dlls.

Finally, right-click the solution in Solution Explorer and select "Clean solution" then build the solution WITH line 86 in the web.config.

Viola, it should compile without errors and the dreaded Invalid access to memory location exception should be gone.

Now, I'm not quite sure why this works but I do believe that when compiling Visual Studio is trying to access all of the referenced components but can't seem to find the Microsoft.SqlServer files.  Yes, all 4 of these files are in the GAC (Global Assembly Cache) which is why I think the error is with the Visual Studio environment.  IMHO, Visual Studio should first check to see if the referenced files are in the GAC and access them there if found.

Note: 
When "publishing" a site, be sure to strip out the Microsoft.SqlServer dll files before pushing live.  Ironically, when the project is fully compiled and published, the error no longer appears (because the .NET framework knows to look in the GAC for the files).  Because of this, my theory that the error is within Visual Studio has some weight.

Credits:
None!  This has taken my team and I quite a while to figure out.  Every week for the past few months, I've Googled this error in hopes that somebody had found a solution to no avail.  

I hope by posting my "solution" (pronounced work around), others frustrated by this error will find this entry and put an end to the elusive (Exception from HRESULT: 0x800703E6) error.

Monday, March 27, 2006 4:01:15 PM (Pacific Standard Time, UTC-08:00)
Holy crap, thank GOD! And I thought I was going nuts. At least the workaround works.
Joe
Monday, March 27, 2006 7:38:16 PM (Pacific Standard Time, UTC-08:00)
I am right there with you! Up to the last minute, I was looking to take replication out of our project during development because it was driving me crazy.
Monday, May 01, 2006 8:04:42 AM (Pacific Standard Time, UTC-08:00)
Another SIMPLE solution (if you do NOT need the SqlReplication dlls):

Right-click the web project, click "Property Pages". In the References section, remove all references to any Sql Dlls. This solved my problem at last!!
Gary
Monday, May 01, 2006 9:54:39 AM (Pacific Standard Time, UTC-08:00)
True enough but one of the referenced projects DID have references to SqlReplication as it was needed. Even when I tried to "remove" the references form the web solution, Visual Studio added them right back.
Friday, May 05, 2006 8:11:28 AM (Pacific Standard Time, UTC-08:00)
Wow, thanks. This was driving me nuts. I really dislike the way Microsoft did web projects in VS2005. I've had nothing but trouble.
Dan A
Wednesday, October 11, 2006 7:46:20 AM (Pacific Standard Time, UTC-08:00)
Hello to all, I think I have an answer to this. I am posting it here because this is the only place I can find that proposes any solution. I think you might find this one interesting:

But first, some background...I attended a seminar last night at the Technology Innovation Center in Milwaukee, Wisconsin. The presenter was excellent - Sean McCormack - Development Services Manager for Miller Brewing Co. (http://www.wi-ineta.org/DesktopDefault.aspx?tabid=23)

I was extremely intrigued by his presentation of SubSonic (http://www.codeplex.com/Wiki/View.aspx?ProjectName=actionpack) Everyone should look at this.

I downloaded the SubSonic package from CodePlex, and attempted to run build/run it in my local environment when I received the "annoying" error. I was convinced that there was an easier solution to this problem.

Reviewing the issue and the symptoms, I concluded that this was a permissions issue. Although I did not have my test project checked into source control, I did notice that the files I downloaded from CodePlex were all marked Read Only.

SOLUTION: I turned off the Read Only flag at the root of my project, and made sure the change applied to all sub-directories and files, and viola!!! Problem Solved.

If you are using source control I would suggest you check out the entire project so all files are writeable. My hunch is that you will only have to do this to the BIN folder, but I did the entire project just to be sure.

I hope this solution works for everyone else out there.
Thursday, October 12, 2006 4:19:30 AM (Pacific Standard Time, UTC-08:00)
@Dan A:
Yeesss, that worked for me too :-)

Thanks a lot!
Friday, November 17, 2006 2:42:20 AM (Pacific Standard Time, UTC-08:00)
For some reason the original solution didn't work for me, but after checking out all files, it worked perfectly.

Cheers
Rohan
Rohan
Wednesday, December 20, 2006 7:54:05 AM (Pacific Standard Time, UTC-08:00)
i had the same problem. Even when i removed every using statement from all the files, visual studio kept adding the references.
I solved the problem by going to the web project->property pages->references and removed all the references from there. everything is fine now!
Antonio dias
Monday, June 09, 2008 7:47:37 AM (Pacific Standard Time, UTC-08:00)
Your 'work around' has helped a lot. Thank you for posting this and making it available to others. Cheers!
Sunday, July 06, 2008 1:14:26 PM (Pacific Standard Time, UTC-08:00)
What worked for me was ADDING the references through the property pages.
Then I could remove the <add assembly...> line from the web.config
and VS did not add it automatically.
Ophir
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview