0

I have written an application to control a merge replication process on a sql server. It is running on my development machine with no problem. On my test install I have installed a SQL Server 2008 R2 64 bit on Win 7 64 bit. When I try to use my replication program it crashes with the following exception message

[ReplicatorClient.exe] - [Fatal] - [1/15/2015 9:29:56 AM] - Version 0.5.16.0 User - vuser Message - Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Stack Trace -
at ReplicatorClient.Models.DatabaseSynchronization.CreatePublication()
at ReplicatorClient.ReplicatorWindow.ReplicatorWindowViewModel.MenuCreateSubscription()

I have copied the Microsoft.SqlServer.Replication.dll that I am using into my bin folder on my developer machine and am installing it in the program folder on the test machine but the program is obviously not seeing it. What steps can I take to figure out what I need to do so this dll can be seen and my application can work correctly when deployed?

I am using WIX to install this.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
PlTaylor
  • 7,345
  • 11
  • 52
  • 94

1 Answers1

0

In general it doesn't really matter then WiX / MSI is your deployment method (as evidence by your manual copy) as it's really a matter of getting the right dependencies automated.

In general you have to profile the assembly load. I always hated this message because it says X or "on of its dependencies". I wish it would just tell me which exactly it is.

You bust out ILDasm and ProcessMonitor to get an idea of what it's trying to load and failing on. Get it (or those) into the installer, reset the VM and rinse and repeat.

PS- sometimes private deploying DLL's is the right thing to do and sometimes installing a prereq redistributable is the right thing to do. There may be a SQL MSI that handles all of this for you and just wire that into your bootstrapper / chainer (if you have one yet) instead. It just takes a bit of research. This isn't a DLL I'm familiar with so I don't have an answer off the top of my head.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • I am trying ILDasm for the first time right now, and when I start it up with my application I am getting a ton of error pop up messages. Is that normal? – PlTaylor Jan 15 '15 at 15:39
  • See Ndepend http://stackoverflow.com/questions/9262464/tool-to-show-assembly-dependencies – Christopher Painter Jan 15 '15 at 15:46
  • It's almost always incorrect to pick and choose Dlls like that. The SQL install has an option to install replication components, and I suspect they are not installed by default. In addition, make sure the bitness of your code matches that of the SQL server http://technet.microsoft.com/en-us/library/ms172376(v=sql.105).aspxcomponents. – PhilDW Jan 15 '15 at 18:22
  • Phil, can you explain what you mean? I typically analyze the dependencies and then look for redistributables where possible or do private deployment where not. I'm not sure what you mean. – Christopher Painter Jan 15 '15 at 18:30