0

I am working on a small project involving a wpf-based UI program when I come to a intellisense problem. It constantly complains that several identifiers (class/method/property) cannot be found, and most of those are from another assembly. Similar issue has been asked by many other users of visual studio:

  1. WPF assembly reference missing - project still building
  2. Type or namespace cannot be found, when reference does exist
  3. Getting "type or namespace name could not be found" but everything seems ok?

If the promble only happens on types in referenced assemblies I might just overlook it. But now even some types in the same assembly are determined 'missing' by intellisense. Today I created a new custom Window in this wpf project, and visual studio auto generated code for further use as follows:

public partial class ReceiveTest : Window
{
    public ReceiveTest()
    {
        InitializeComponent();
    }
}

Then intellisense told me that identifier 'InitializeComponent' cannot be found, and every control this window owns cannot be found either. This is really upsetting since it makes intellisense completely useless. Normally these 'missing' identifiers are declared in FileName.g.i.cs and managed by visual studio itself, however it seem visual studio somehow failed to recognize it.

Now I have done everything I can including solutions given in above links but failed again and again. Could anyone explain this problem and show me a way to solve it? I would be very very grateful.

P.S. I am using visual studio 2017 and PowerTool addon

Community
  • 1
  • 1
Tommy T
  • 55
  • 7
  • Sometimes you just need to save and rebuild all projects and it works just fine, in my case it is. – ivica.moke May 22 '17 at 06:24
  • Does your Project build? Try to restart Visual Studio then. – mm8 May 22 '17 at 09:54
  • Restarting visual studio caused it to crash for once, but then the 'InitializeComponent' part of the problem kind of solved itself. However types from other assemblies are still marked 'undefined', and every assembly's target platform is set to .Net framework 4.6.2. I don't know how to eliminate this problem completely, but at least I can proceed on my work now. – Tommy T May 22 '17 at 12:29

1 Answers1

0

Upgrading Test project from 2010 to 2017

Following this up on a recent problem with a test project on VS2017 after upgrade from 2010. Tried everything to get rid of the squiggly red and they wouldn't go.

Problem was that 'namespace.zone.section' had 'namespace' not found when it was there and seen by intellisense etc (and in some cases 'zone' or 'section')

  1. Deleted sou files
  2. Deleted project files
  3. Deleted the references
  4. Reapplied all after clean, restart, restart server and all the above.

    Still problem persisted.

So I deleted the test project (imported form 2010) recreated the project in 2017, copied all the original test classes into new project, added back all the other projects (supporting the tests), added moq etc back in. Only took about 20 mins.

And ... compiled and worked.

Conclusion was that the original project file (test project) had something in it that didn't get upgraded and screwed it all up. Anyway it is all fine now.

I post this so you don't have to wast your time.

John Irvine
  • 156
  • 2
  • 7
  • It's not obvious how this relates to the original question, even if it might be useful experience to share. Could you edit to make clearer how this might help with the original question? Thanks. – rwp Apr 06 '18 at 13:47