How to fix "Object reference not set to an instance of an object" error in Orchard CMS - nullreferenceexception

I'm building an orchard CMS site. Initially, I downloaded the zipped version, but VS complained of the error: "Object reference not set to an instance of an object" in project Markdown.csproj, line 1. This made no sense to me, so I tried installing it from Web Platform installer. That worked great for a while. Then I restarted visual studio after some theme changes and got the original error again. I've attempted to revert the theme changes and tried relaunching VS in admin mode. Still no dice.
I can find absolutely nothing on the subject of Markdown.csproj via google. If anyone has suggestions I'm all ears. Thanks.

In case anyone else runs into this, the solution for me was to migrate to orchard 1.4 via the source instead of web platform installer.

Create a new project.
Move your orchard files to the new project replacing all existing files and folders, except; .cproj file(s), Properties folder.
Clean
Build

Clean you solution and recompile. I have had this happen to me, not with that module specifically, and cleaning up the binaries has solved it for me.

Related

Having trouble compiling an Orchard (v.1.5) project in Visual Studio 2013

First, I have no experience with .NET at all, I'm a front-end developer.
I agreed to help out someone with a website they own since they can't get in touch with the guy who originally set it up. It's running Orchard v1.5.1.0. I was under the impression that I could just download the entire wwwroot/ folder over FTP and open it as a webpage in Visual Studio (I'm using VS Express 2013 for Web).
Now, my problem is that while I can run the app just fine (I guess because I also got the bin/ folders with their DLLs when I fetched the whole thing over FTP) Visual Studio complains about compilation errors when I try to build it.
In one of the Modules, Amba.ImageMultipicker, there is a Views/Admin/Index.cshtml file that gets an error on the first line where it tries to do #using Orchard.Media.Services, and the error is The type or namespace name "Media" does not exist in the namespace "Orchard" (are you missing an assembly reference?).
(I have an Orchard.Media folder under Modules, so it's there. Somewhere.)
I have tried
Adding <add namespace="Orchard.Media" /> to web.config
Dropping the DLL from the bin folder in the Orchard.Media module into Dependencies
Verified that Amba.Imagemultipicker.csproj has a ProjectReference to Orchard.Media.csproj and that the relative path is correct.
Am I missing something extremely basic here? I really don't want to go back and say I can't help out, but if I can't get the flipping thing to run locally there's no way I am going to start modifying their Themes and hope it works on the production server.
Sidenote:
I thought it was wierd that I didn't get a bin folder for the module when I downloaded the entire site, and I notice there isn't one on the live production site either. Is it possible that the whole site is running with this error?

Namespace not found within the same project according to intellisense, yet project builds

I have a simple ASP.Net MVC project which for some reason has issues with intellisense. It is constantly giving me errors that namespaces local to the project can not be found, even though they do exist and the project will build fine. Here's an example:
It is very frustrating as this results in me having no intellisense available whatsoever. Has any one encountered a problem like this before, and do they know of a solution?
The project itself is an MVC4 website running in VS2013 in W8 under Paralells on a Macbook Air, should that have any effect on the problem.
As stated, I have no error messages to provide as the project builds and runs successfully, but please let me know if more details are required.
I had the same issue. Try removing your project from the solution and then add it again. It worked for me. Looks like a solution file quirk.
UPDATE: this is not a permanent fix as closing and reopening visual studio brings back the issue.
UPDATE 2: while looking to fix another issue where I couldn't change the default namespace of a project (I would get a System.Runtime.InteropServices.ExternalException), I found out that it was related to Xamarin tools for Visual Studio. I proceeded to completely uninstall Xamarin. It fixed my namespace renaming issue as well as the weird type or namespace not found / intellisense issue.
I had this same issue, seems to be something with the solution file and building the project as I could replicate the problem by simply creating a new project building then restarting visual studio.
Anyway I get around it at the moment by deleting the solution file and opening the project using the project file.
For anyone reading this in 2020, a fix that I've found that has worked for me is:
cleaning the solution and unloading the projects that have dependencies such as a web API depending on a data project and an application project (right click on the project in solution explorer and find "Unload Project"),
then reloading and building each project in the order of dependence such that they build successfully (right click on the unloaded project in solution explorer and find "Reload Project").
so in my case my data project does not depend on any other project so I reloaded and built that first, then the application project which depends on the data project and finally the web API project which depended on both data and application.

Dotfuscator 4.10 project in VS 2012 bugs while trying to save .dotfuproj file

I recently installed Dotfuscator 4.10 on my computer and I already has VS 2012 working on it. Everything worked fine up to the point when I tried Dotfuscator embedded in VS (I mean the standalone GUI app works perfectly).
Just for the try, I created a small solution (no TFS/VSS) with a C++ /clr app, a C++/clr dll and a C# app.
I then added a Dotfuscator project. To this project I added the output from the three dll/exe other projects.
When I tried to rebuild the solution, I was asked to save the .dotfuproj file. Strange and abnormal behaviour, the file should be saved automatically and without prompting me. OK, I chose to overwrite the existing file (what should have been done automatically after all.) I got the error Object reference not set to an instance of an object. I had to cancel the operation and could not build the solution.
Note that I observed the same behaviour if I tried to save the dotfuproj file under an other name. Also, the file is not R/O.
My question: has someone experienced this problem? Any solution? Thanks for your help!
You can try deleting your Dotfuscator project and then creating a new project. If that does not work, try using direct input to the Dotfuscator project, rather than using the output of another project within your solution.

The working directory does not exist in Visual Studio 2010

I am using Visual Studio 2010.
I wanted to study some code that dumps relevant data in a database, find out how it works and adapt it to my own version.
I only got as far as loading the solution in VS 2010, hitting the "Start Debugging" button, and then I got this error:
The working directory does not exist:
'D:\Dev\CodeProject\articles\smartcardfmwk\Smartcard_Framework
How can I fix this error?
The source code in question is Smart Card Framework, from Code Project
I downloaded the "Updated Project (VS2010)" and I can open it in VS2010, as well as build, but debugging just wouldn't work.
I did not try replicating the path yet, but as this is a working project, my company requires that it is placed on a very specific location accessible by others.
Nevermind, I got it. It was so simple, I'm sorry for wasting anyone's time.
The source Solution had a lot of Projects under them. I figured at least one of them was pointing to a directory that doesn't exist, so I waded through the Projects,
I right-clicked a Project and clicked the Properties
This will open up the ProjectName Property Tab
Under the Debug tab, there is a filed called "Working Directory"; I changed it to where the project is currently located.
This solved my problem, for now, unless there's a Project I missed. I am wondering, though, if I have to do this again if I move the Solution elsewhere.
This happened also in VS 2019 after importing / upgrading an old C# project. I was not able to see any project properties to change.
Finally it was fixed by manually editing the file <ProjName>.user.csproj as follows:
Replace
<StartWorkingDirectory>[wrong directory name]</StartWorkingDirectory>
with
<StartWorkingDirectory>.\</StartWorkingDirectory>
I also faced this problem that working directory does not exist, but I managed to solve it. There are certain steps to follow properly Whenever this error occurs.
In VS, open the "Project" at Toolbar.
Then go for Project properties.
Select Debug And check your working directory. If the path is wrong just browse it...

Problem after publishing web application from VS 2010

Whenever I publish my MVC web application in VS 2010 via the One-click publish feature (I'm not doing any web.config transforms or anything fancy - yet!). The next time I come to build the app I get the following error:
It is an error to use a section registered as allowDefinition='MachineToApplication'
beyond application level. This error can be caused by a virtual directory not being
configured as an application in IIS. in ...MyWebApp\obj\release\package\packagetmp
\web.config
A new copy of the web.config file is indeed created by VS2010 below the ...MyWebApp\obj\ folder so I deleted the whole obj folder and I was then able to build again.
But I shouldn't have to do that each time I publish - I must have something configured incorrectly - can anyone help please.
Thanks.
This is unfortunately a known issue with Publishing a web application to the file system. This still affects the release version (RTM) of Visual Studio 2010. It's not limited to the Beta or RC versions.
This problem "bit" me also, and I too was having to manually delete the Debug and Release folders inside the obj folder within my web site solution folder.
The real answer for an automated "workaround" can be found in this answer to the other Stack Overflow question:
Why do I randomly get a “error to use section registered as allowDefinition='MachineToApplication'” when building an MVC project?
In a nutshell, you need to delete the web.config files from either the Debug or Release folders (or both!), and that's achieved with a pre-build command (configured in the Build Events tab of the Project Properties page of your solution):
del "$(ProjectDir)\obj\Debug\Package\PackageTmp\web.config"
del "$(ProjectDir)\obj\Release\Package\PackageTmp\web.config"
Personally, I delete the entire obj folder since all those files are re-created with each build anyway.
I have just found a work around for this that has worked for me, open the .csproj for your web project and change the node under the Project\PropertyGroup node to this:
from this:
<MvcBuildViews>true</MvcBuildViews>
to this:
<MvcBuildViews>false</MvcBuildViews>
This has worked for me, hopefully it will work for you also.

Resources