snakile
snakile

Reputation: 54521

Resharper keeps complaining that a namespace doesn't correspond to file location even though it does

I am working on a WCF project. The name of the project used to be ServiceTemplate and I have decided to change it to something more indicative. I have done the somewhat painful job of renaming the project according to the following steps:

Even after all these steps, Resharper still complains the namespaces don't correspond to the file location. Strangely, Resharper still suggests changing the namespace to "ServiceTemplate.Something" even though the string "ServiceTemplate" is nowhere in the solution, neither in folder/file names nor in file contents.

What could've caused the problem and how do I get rid of it?

Upvotes: 10

Views: 5153

Answers (2)

dynamiclynk
dynamiclynk

Reputation: 2331

You will need to modify the property\element in the .vbproj or .csproj file. As suggested by @citizenmatt.

Proposed Change:

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
 <PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  <ProjectGuid>{14E9B75E-02B5-4371-912F-674B7E199796}</ProjectGuid>
  <OutputType>Library</OutputType>
  <AppDesignerFolder>Properties</AppDesignerFolder>
  <RootNamespace>My.Default.Namespace</RootNamespace> //<-- Change this
  <AssemblyName>My.Assembly.Name</AssemblyName>
  <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
  <FileAlignment>512</FileAlignment>
</PropertyGroup>

Upvotes: 0

citizenmatt
citizenmatt

Reputation: 18573

You also need to make sure you change the default namespace in the project properties, next to where you change the assembly name. ReSharper also uses this when deciding what the namespace in a file should be.

Upvotes: 24

Related Questions