-3

I am sharing a C# project with a colleague so I have moved the entire folder containing the project to his PC. He are both running VS 2012. Anyway when opening the solution we get an error. All the classes still have the path of the origin PC so when trying to run on the other one it is not able to find the class. I don't know why this is happening. I want to use the classes in the folder not the ones in the origin PC. Even if they are exactly the same we don't have access to that PC now. How can I fix this and tell VS to use the classes in the folder I have moved to the new PC?

EDIT

I have fixed the path so it is using the ones in the correct folder. The main function is:

class MainClass
{
    public static void Main()
    {
        myInputForm myInputForm1 = new myInputForm();

        myInputForm1.ShowDialog(); // show interface to prompt user...             
    }
}

The error that occurs when the ShowDialog() method is called is:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll Additional information: dragdrop registration did not succeed.

opt
  • 477
  • 1
  • 10
  • 25
  • 3
    What is the exact error you are getting. It sounds like you hard coded all of the paths in your code. – deathismyfriend Oct 25 '14 at 18:17
  • You should be more specific about exactly where the paths are wrong. In some cases, you can just browse for the correct path in VS, in other cases you'll have to edit the .sln and/or .csproj directly to fix it. You already have one answer that should at least get you pointed in the right direction, but if you'd be more specific, it would be easier to make sure you're getting advice that's appropriate. – Peter Duniho Oct 25 '14 at 18:23
  • Thanks I have added some information. – opt Oct 25 '14 at 18:33
  • If your solution is loading and building successfully, then it sounds like your question has been resolved. You should ask a separate question for the DragDrop registration problem (after searching to make sure someone hasn't already answered it). – RedGreenCode Oct 25 '14 at 18:36
  • No it is not building. It stops at the very beginning without even loading the form. – opt Oct 25 '14 at 18:38
  • If you select Build -> Build solution and Visual Studio gives you a "Build succeeded" message at the bottom left, then your project path problem is resolved. If you're getting an error when you run your solution (e.g., when you select Debug -> Start Debugging) then that's a separate issue. You'll get better answers by creating a new question. You can also take a look at the link from http://stackoverflow.com/questions/659825/systemwindowsformsformshowdialog and see if it helps. – RedGreenCode Oct 25 '14 at 18:47

2 Answers2

1

If you open up your .csproj files in Notepad, you can edit the file paths directly. Generally you want to use relative paths rather than absolute paths so you don't run into this problem.

To see the difference between relative and absolute paths, look at the code examples in Which one is correct approach for assembly reference in csproj file?.

Community
  • 1
  • 1
RedGreenCode
  • 2,195
  • 1
  • 25
  • 33
  • Note that you can actually edit the .csproj in VS as well. This is sometimes more convenient than using a different editor (especially as compared to Notepad, since VS knows XML but Notepad doesn't). Right-click on the project in the Solution Explorer and choose the "Edit" item (if the project itself has loaded successfully, then you'll have to choose the "Unload Project" menu item first). – Peter Duniho Oct 25 '14 at 18:21
  • Thanks for the comment. I changed the path but now I am getting another error: System.InvalidOperationException occurred in System.Windows.Form.dll... Additionl information: DragDrop not succeeded. – opt Oct 25 '14 at 18:24
1

Make an account on Visual Studio Online for TFS Source Control and manage your project in source control. It is free for up to five users. Then you can share the project and both have copies of the source code.

Ryan Mann
  • 5,178
  • 32
  • 42