Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to connect to SVN via Visual Studio 2019 and the .NET 5 framework. My requirement is to get the list of repos under SVN. I am able to move the repo from one SVN repo to other, then upload the code to SVN.

All the mentioned items have to be done with C# code.

What I have tried:

I tried using Visual SVN/Sharp SVN, but it's not compatible with the latest VS 2019 + .NET 5 Framework.

This is the code I'm using to try to connect to client with Sharp SVN:

C#
var  client = new SvnClient();
            //client.Notify += new EventHandler<SvnNotifyEventArgs>(client_Notify);
            client.LoadConfiguration(Path.Combine(Path.GetTempPath(), "Svn"), true);
            try
            {
                client.Authentication.SslServerTrustHandlers += delegate (object sender, SvnSslServerTrustEventArgs e)
                {
                    //You might want to double-check that the server is trusted, instead of accepting them blindly.
                    e.Cancel = false;
                };

                SvnLogArgs args = new SvnLogArgs(new SvnRevisionRange(500, new SvnRevision(SvnRevisionType.Head)));

                System.Collections.ObjectModel.Collection<SvnLogEventArgs> revisions;
                client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(userName, password);
                client.GetLog(new Uri(uri), args, out revisions);

                foreach (var item in revisions)
                {
                }

I'm getting the following error:

System.BadImageFormatException: 'Could not load file or assembly 'SharpSvn, Version=1.6003.1304.38397, Culture=neutral, PublicKeyToken=d729672594885a28'. An attempt was made to load a program with an incorrect format.'
Posted
Updated 14-Feb-22 9:05am
v2

1 solution

Your SharpSvn dlls are not getting resolved properly. Check the dlls you are using and Target Framework. If you are targeting to x86, use the x86 dll, or if your target is x64 then use the x64 dll to resolve this issue.
If you are getting this error after deployment on IIS, check the application pool settings.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900