Problem loading a referenced assembly in Visual Studio 2010 - visual-studio-2010

Here's the official problem reported by the compiler.
Could not load the assembly
file:///Q:\Libraries\v2.0\v4.0.30319\Silverlight.dll.
This assembly may have been downloaded
from the Web. If an assembly has been
downloaded from the Web, it is flagged
by Windows as being a Web file, even
if it resides on the local computer.
This may prevent it from being used in
your project. You can change this
designation by changing the file
properties. Only unblock assemblies
that you trust. See
http://go.microsoft.com/fwlink/?LinkId=179545
for more information.
Now I've been a good programmer and did some research to fix this. Here's what I've tried so far.
Copy the assembly to a FAT32 drive (flash drive) and then back.
Unblock the assembly by hitting the Unblock button in the file properties. (Actually never have been able to get this to work since the button isn't there to begin with)
Use the type command in command prompt
Short of disabling this feature, I'm not sure how to fix this problem. Sometimes it happens, sometimes it doesn't. I should mention that the Q: drive is a network drive on a separate server. My machine is running Windows 7. The assembly Silverlight.dll is a library created by some of the developers here at work. We just placed it on a shared network drive so everyone could find it easily. Even if I log onto the server and look at the file properties, there isn't a Unblock button like in all the tutorials I've read.

Copy the file onto your local drive (maybe somewhere into the solution/project dir) and then right-click the file in Windows-Explorer.
In the file properties window you will find a warning that this file comes from a remote computer and a button to permit access (In German "Zulassen"). Click it! Now rebuilding your Silverlight application will work.
Screen shot:

copy it local (I create a Libs folder for all dlls copied locally).
add it as a reference to your project.
in windows explorer right mouse click on the dll and click the UnBlock button on the main tab.
build Silverlight project.
error goes away.

Related

Cannot open other member's project in Team Foundation Server?

I don't understand how it works. I'm new to Team Foundation Server and currently I have a small team. The co-worker can open my project file and run just fine (by double clicking the solution file right in the source control explorer window).
I can open my project file the same way but cannot open his project file. Clicking the solution file does load the solution but the files in there cannot be opened. It says something like this:
Cannot find the file "d:\....". It may have been moved or deleted.
The path "d:...." is actually the path on his machine. While in my machine it's mapped to a different path. But I don't understand why it cannot recognize it.
At first I thought the mapped path structure should be the same across all members' machines but if so my co-worker could have not opened my project file.
The status of the solution is Yes for Latest, meaning the files are loaded and copied to my local folder normally. Not sure if it matters but I'm using Visual Studio 2015 and my co-worker uses Visual Studio 2013.
I've tried searching around but could not find anything with the error message. It's so interesting that my co-worker does not have to do something special or self-aware so that he could tell me something to solve this. I hope you have some experience on this and give me some helpful suggestion. Thank you!
Edit:
To clarify it more, if I browse the file directly inside the source control explorer window, the file can be opened (but if it such as is some designer-supported file like .xaml - the designer then is not shown up). What I'm having trouble with is opening the file loaded in the solution (inside the Solution Explorer window). As I said clicking the solution file in Source Control Explorer window does load the solution, but because there is something wrong with the files path, I cannot open them as well as build and run the solution.
Right-clicking on the file in the loaded solution, select Properties, I can see that the Full Path is actually the path on his machine, so weird.
It sounds like your workspace is all messed up. Are you trying to share a workspace?
If so you should not. Each developer should have their own workspace local to their computer that is unique to them.
Try creating a new workspace and using that...

WP7 app could not start for debugging

I have to create around 200 WP7 apps that are very similar. They differ only in the content, icons and name. So manually create them isn't a good idea so let's I've written a little tool, which does the following:
Copy the created template project
Copy the content files from a source directory to the copied template.
Change the app name, tile name and app id in the WMAppManifest.xml
Add the copied content files in the .csproj-file.
This works and the generated project opens error-free in Visual Studio 2010 and compiles without errors. The xap-file can be deployed on device and emulator.
The problems:
If I want to debug the app by pressing F5 in Visual Studio I get "The application could not be launched for debugging. Ensure that the target device screen is unlocked and that application is installed", both for device (which is unlocked and connected with Zune/WPConnect) and the emulator.
If I try to start the app on the emulator it closes immediatle after start. BUT if I start the app on my device it works like a charm. Crazy stuff.
The curious stuff: If I do the things which my little tool does manuelly I can debug the project from Visual Studio.
This only occures with my generated projects. Every other WP7 project (existing or newly created within VS) works and debugs error-free.
I tried to PCs: Win7 x64 with VS2010 Ultimate and an other one Win7 x64/VS2010 Pro and on both maschines I have the problem.
Maybe someone has an idea which causes the problem. Thanks for the help!
Edit: I've seen something new: The AssemblyInfo.cs file is located in the properties folder and correctly included in the csproj-file. But if I try to open the Assembly Information from the project properties all fields are empty and if I try to set them I get an error ("value is not in the expected range" or something like this).
I've got similar problem with some sample programs.
It turned out that I have to set in a Solution properties:
Active config => Debug|Windows Phone
it works for me
If they only differ in content, icons, and name, would it be simpler to make one complete app, copy it 199 times, and then just put the appropriate files into the correct directories?(if you made a tool to make templated projects, i'm sure you could do this with code too)
Plus that way if you ever need to change the program you can just recopy with that code again, but not copy the content, thus updating all of your individual 200 apps.

How can I protect a source file when debugging?

I've got an app that uses our DAL and when I run it in debug mode (vs2010) and purposely try to make the app crash (for instance, leave the connection string empty of the DAL), vs2010 opens the code for the DAL at the point in which it crashed. Which is ok, but I'm then able to edit that .cs file and save changes, which I don't want. I've verified this by having the DAL project opened in another instance of vs2010 and when I make the app crash and change the DAL.cs in the app and save it, the DAL in vs2010 tells me that the file has been modified outside the project and asks if I want to reload it.
How can I prevent this from happening? The only reference I am using to DAL in my app is the reference to the DLL, that's all.
The AssemblyName.pdb file links the compiled DLL to the original source.
Visual Studio uses this file to display the source code when debugging.
You can delete this file and get rid of the source link.
This will give you a vastly inferior debugging experience.
Have you tried going to "Tools > Options > Debugging > Edit and Continue" and unchecking "Enable Edit and Continue"?
Make the .cs file(s) read-only. If its read-only, you'll be able to see it, but you won't be able to save changes. (Depending on your Visual Studio settings, you might still be able to edit the file in memory, but that seems irrelevant, since the changes you make won't be persisted to disk.)
If you need more fine-grained control (like where you want to be able to edit the source files, but not your testers), you can use access control lists (ACLs). Ask more questions about that on Server Fault.
Yes, you could disable debugging or turn off the generation of PDB files, but that makes it very difficult to debug the code, which is probably the reason why you're purposely trying to make the app crash.

Xap packaging failed. Object reference not set to an instance of an object

I'm getting this error message on my PC when I try to build my Windows Phone app:
Xap packaging failed. Object reference not set to an instance of an object
I'm using Dropbox. On my laptop, It works perfectly fine and I can debug etc...On my PC however, I can't.
I tried many things such as:
Delete obj/Debug Folder
Check for files which are missing on the Solution Explorer
So far, nothing has helped.
Any idea how I can fix this?
You should check, in every folder of your project, for missing files or wrong references.
You can get this problem just with a single missing image, if its Build Action property is set to Content or similar...
Check your files and then Rebuild your project!
This can happen if a file is removed from the disk itself, but not from the Solution through Visual Studio. Delete the file through Visual Studio (it should be marked with a little yellow hazard icon) and Rebuild.
Credit to Andreas Hammar via http://blog.jayway.com/2011/06/03/wp7-build-error-xap-packaging-failed/ - his solution worked for me.
I am adding this reply because although the problem with app icons is covered in brief in some of the answers above, I wanted to give exact steps since it just happened to me. I got this error and then found this web page:
Xap Packaging Error
It turned out that my App icon file name was wrong due to a rename. I double-clicked on WMAppManifest.xml, found in the Properties folder, to open the editor for that file. I simply used the button to update the App Icon, re-found the file and selected it, and the error went away after rebuilding the project.
The problem lies in your startup object in your Application. I have met this error to many times.
It usually happens when I change the name of my class/namespace Application class. Or it might even be conflicting with your dropbox locations.
To Fix this.
Right click your main project or Alt+Enter
Go to the silverlight tab and set your startup object
Try the following:
Have Visual Studio closed
Download all your files to your computer
Delete Bin and obj folders completely.
Open the .sln
Rebuild
If if fails expand the References in te Solution explorer and make sure all your dll's are found. If a dll have a yellow exclamation point that means its not found. I'm thinking that one of your references are set to an absolute path on your laptop and that's missing on your PC.
If someone comes across this post and still has the issue I had where XAP packaging failed and that VS2012 can not find the file then check for spaces in the file name.
I had the issue where my tiles were "tilename 99.png" and it keep giving me the XAP packaging failed message. So I finally changed the file name to "tilename_99.png" and it worked.
Hope this helps someone in the same predicament.
In my case, I'd accidentally moved Background.png to a resource folder. Moved it back and it worked!
In my case, this error didn't go away even after trying all the above methods. Actually I had renamed the ApplicationIcon.png to "xyz.png". And reverting this, fixed the issue.
One more possibility is that you have a wrong path to an image in the project/options/Application dialog (icon, bg image, etc).
I had this error message, after some frustration I look in the obj folder, is was no part of the solution(but visual studio need it) but I had some conflicts files with dropbox. I deleted the obj folder rebuild, visual studio recreates the folder and the content of it and problem solved.
Ahh finally found my problem.
I'm using Visual Studio 2012, which doesn't always point out the "missing" file and makes it a little harder to fix.
MY SHORT SOLUTION
Relink the "linked" configuration file in the main project. It is a linked file because the original file remains in a referenced assembly, not in the current assembly. The file wasn't marked YELLOW so it wasn't obvious that it would be the problem, but when I double clicked on it, it failed to open, so I knew this was the problem file.
The silverlight application itself had a "linked" file called "ServiceReferences.ClientConfig" which contains information needed by a referenced project to make a web service call.
So the main project didn't have the web service reference itself, but it referenced a project which did, which is why it linked the "ServiceReferences.ClientConfig" file.
MY LONG SOLUTION
Keep rebuilding the main project file, and commenting out, and excluding project by project, file by file, until you CAN build the main project again. At that point it should be clear(er) which part of the solution is causing the problem.

Why is loaded dll missing in Visual Studio's modules list?

I am currently bug hunting and need to debug into a specific dll in the release configuration in Visual Studio 2005.
At some point I closed the solution, did some other stuff and reloaded it. From that point on my breakpoint doesn't get hit and I get the infamous "No symbols have been loaded..." message. So I opened the modules window and the dll that I want to debug doesn't appear in the list anymore, therefore I cannot load symbols manually. The application behaves normal so I am absolutely sure that the dll MUST have been loaded to execute certain functions. Sure enough, if I rename the dll and start up the application it doesn't work anymore, so it also must be the right dll.
I tried setting the dll project as startup project and the command to execute to the application's exe and starting the application from outside visual studio and then attaching to the process, all to no avail.
Question is, why is the dll not appearing in the list of loaded modules although it must have been loaded? I cannot think of any other changes that I've done, that could cause this, am I missing something? (Maybe something really obvious?)
Any help appreciated!
Use process explorer to check if the dll is loaded or not.
When you attach the process make sure that you are enabling both 'Native' and 'Managed' code type (in the code type selection option).
See also this question: Visual Studio is not loading modules when attaching to process
I encountered a similar issue after transferring a project from one computer to another. I will simply explain what I discovered and how I fixed it, and you can determine if it fits your problem and solution.
The work computer I wrote an application on contained a .dll file which my program was referencing. After moving the application to my home computer, the application could no longer locate the .dll file it was previously referencing because the file was no longer there.
The application compiled and ran even without the referenced resource (.dll file) because the previously compiled assembly (debug folder) contained its own copy of the .dll file and other resources. Put simply, it is the old assembly build that is running and not the current application you're working on. This is also why this error tends to suspend the designer window and throw an error after the app is done running.
I would take a look at the following:
a) Under Solution Explorer, go into the References folder and right click the missing reference node and select properties. In the properties box, observe the Path of the resource being referenced. Is the resource still located at this path?
b) Check the debug folder for a copy of the resource you're looking for. If the resource is there, make a copy and save it to your desktop. If it's not there, get the file from the original source.
c) Under Solution Explorer, right click 'Properties' and 'open'. From the menu that appears select 'Resources' from the left and at the top of the new window that appears you you should see 'Add Resource' with a small drop down arrow. Click the arrow and select 'Add existing file' and then browse to the file. If you don't see it you may have to change the file being browsed from the small drop down above the 'open' and 'Cancel' buttons. After the file is located it should create a new folder in the solution explorer called 'resources.' Now the file is a permanent part of your application and not merely a reference to it.
I had the same issue today with Visual Studio 2008. I was using a simple tester to test a new method in an assembly. So added a reference to my assembly I wrote the code to load the assembly and call the new method, build, everything OK. But during execution the debugger would throw an exception saying that new new method did not exist, and the modules window was empty.
Turns out the assembly I was modifying was in the GAC, and was using instead of the new one in my build directory.
I had the same issue with visual studio 2017 Pro and searched for a week but no luck then i installed VS2019 Pro and test with same project but the break point wasn't working at all and the project's DLL was missing from the modules list.
I was running multiple projects under one solution and i suddenly observed that if select project1 as "Startup Project" the DLL of that project is loaded only in the module list. So as i was testing an API and I switched API project as Startup Project and observed now the API DLL files are loaded into the modules list.
Right Click on your required project that you want to include it's DLL files in the module list and set it as "Startup Project"

Resources