14

I'm running Visual Studio 2010 on a terminal server, and have been, with relatively few problems, for some time. This morning I fired up my PC and over the UK's long weekend, the following issue seems to have developed.

I've got a bunch of projects (but not all of my projects, and not all of the projects in a given solution) complaining that a particular file (which does not exist on the computer) cannot be opened, and so those projects will not compile anymore. Here's the error:

Error   31  Unable to open module file
'C:\Users\[username]\AppData\Local\Temp\2\.NETFramework,Version=v4.0.AssemblyAttributes.vb':
System Error &H80070003&

I could simply copy the file into that directory and be done with it, I'm pretty sure that will work, but I would appreciate any insight anyone can give me into why this problem has occurred, and what I can do to avoid having it happen in the future.

EDIT: Okay, now things have gotten to a whole new level of weird. I've rebooted the server, I get the same error message, only now the file it is asking for exists and can be opened in Visual Studio with no problems.

And yet, another part of the IDE still insists that it's unable to open the module file...

EDIT 2: Can't delete the file because it claims to be open in another program, but I've logged off and logged on again, and there shouldn't be anything accessing it.

EDIT 3: Because there's a wall of comments below his answer, I'll mention here that Jared's suggestion to delete the SUO file for the solutions having the problem (not files specifically to do with any of the problem projects, strangely) was what solved this, eventually.

Frosty840
  • 7,965
  • 12
  • 50
  • 86
  • 4
    It's a weird feeling, finding a stupid problem with Visual Studio, feeling sure you've heard of this one before, and googling your way back to your own stackoverflow post from 18 months ago. Same problem, same solution, over a year later. – Frosty840 Dec 05 '12 at 10:25

3 Answers3

16

If you've verified the file doesn't exist and are still getting that message the most likely answer is that the permissions on that directory don't allow your user account to write to them. Try creating a file in that directory and see if it succeeds. If it doesn't then you know this is the problem and you will need to correct the permissions

From "Edit 3" above and the comments below: the solution to this problem was to delete the *.SUO file from disk and open the solution again.

Abel
  • 56,041
  • 24
  • 146
  • 247
JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • 2
    Sorry, I guess I wasn't quite clear. The problem directory is the Temp folder in my own user directory. I have read/write access there. There's actually also a \3\ directory in \Temp\ (the question asks about a \2\ directory) and the \3\ directory contains the missing file. It's just that none of this has anything to do with my code or anything I've done deliberately, it's an IDE issue. I don't play with C:\Users\ at all anywhere in the code... – Frosty840 May 31 '11 at 14:58
  • @Frosty840 have you verified that you can indeed create a file in that directory? – JaredPar May 31 '11 at 14:59
  • @Frosty840 that's very odd. Couple of standard Q"s. Have you tried restarting Visual Studio and or the computer? I realize it's a TS session so have you tried fully logging out? – JaredPar May 31 '11 at 15:16
  • Yes to all of them, I'm afraid. I might try rebooting the server (well, the virtual server. My boss is really loving the server virtualisation thing, but it's leaving me feeling pretty freaked out and helpless, tbh) later in the evening after the other devs go home, I guess. – Frosty840 May 31 '11 at 15:47
  • Yeah, well, I just checked on the server, noticed there was only one other developer on it, asked him really nicely to go do something else for ten minutes and rebooted it. Still exactly the same issue. – Frosty840 May 31 '11 at 15:59
  • 1
    @Frosty, I'm grapsing at straws at this point. My next step would be to delete the .suo file, all proj.user files, and possibly even wipe out the cached visual studio data under AppData Local and Roaming. – JaredPar May 31 '11 at 16:02
  • Well, I'm tired and angry and confused, so I'm going to go home and stew on this overnight, come back to work calm and *not* format the server in a big hissy fit, which is how I feel right at the moment. Thanks for your help. – Frosty840 May 31 '11 at 16:12
3

This is a problem caused by Remote Desktop Connections. RDC is (by default) setup to use create a new directory each time you log in remotely. Also, it's setup (separate setting) to delete that directory once you log off. The real solution is to remove these two settings so that it will just use your standard Temp folder, not deleting the files at logout.

There are also two workarounds to this problem:

  1. As mentioned elsewhere, delete your .suo file for the solution before opening the solution or rebuilding.
  2. Use the "Rebuild All" option when rebuilding. (This sometimes works.)

Note: Setting up RDC can really only be done if you're logged on as an administrator on the box, thus, the two workarounds.

Richard
  • 6,215
  • 4
  • 33
  • 48
  • I had the same error after remoting into my PC and then logging in locally. Deleting the .suo fixed it. – Paul Anderson May 16 '13 at 00:53
  • Here's a link on configuring the Remote Desktop temp folders: http://technet.microsoft.com/en-us/library/cc755098.aspx – Paul Anderson May 16 '13 at 00:54
  • Which is...exactly what I said. However, as I also said, the real issue is the Remote Desktop issue. Fix the remote desktop issue and you won't have to deal with the invalid pointer in the .suo file. – Richard May 16 '13 at 13:26
  • Thanks Richard, I was just adding weight to your answer for anyone else who comes down the same path. – Paul Anderson May 16 '13 at 13:36
0

02/17/2015 Update: Had the same issue again this morning with the first application I opened in VS2012. Just running Build/Rebuild Solution solved the issue. Additional apps opened this morning did NOT have the problem.

Build/Rebuild Solution resolved the problem.

When I came in this morning, I had the same problem as above however; Windows 7 was stating I needed to reboot after a second (automated) attempt to install a patch. So I shut everything down and restarted.

Loaded one of my projects and it displayed the same message. So I loaded a second project in a new session of Visual Studio and it had the same error message.

Went to the first project and attempted to run Build/Rebuild Solution. That ran successfully and fixed the problem for both projects.

Using Visual Studio 2012 Enterprise Edition.