KryptonForm not showing in designer - Visual Studio 2013 - c#

I've added the toolkit.dll as a reference, inherited KryptonForm instead of Form, successfully built the application, everything is working fine, but designer mode fail to display the form. I am getting this error:
Could not find type 'ComponentFactory.Krypton.Toolkit.KryptonForm'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

I found the issue: I renamed the dll thinking that will not affect in any way the application, and it didn't !
But somehow affects the designer: when I renamed the dll back to ComponentFactory.Krypton.Toolkit.dll Visual Studio's designer worked aswell. I am curious why behaves this way

Related

Intellisense showing identifier not found error when everything build successfully

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:
WPF assembly reference missing - project still building
Type or namespace cannot be found, when reference does exist
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
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')
Deleted sou files
Deleted project files
Deleted the references
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.

Weird: C# Type or Namespace name could not be found - Builds successfully

I have a weird error showing up in my project when it is open in the VS2012 IDE. Everywhere where I make use of another referenced project it suddenly says "Type or Namespace name could not be found". And by "says", I mean it has the text underlined in red with the error when I hover over it. The intellisense doesn't work for that code. BUT (and here's the weird part), the errors do not show up in the error console and the project builds and runs fine.
I can even debug and step through the code and it works perfectly fine. So at runtime the project is referenced fine but at design time the IDE can't find it. This worked for the past 2 weeks, and only then suddenly went a little bonkers. It's really annoying because I am rubbish at coding without intellisense!
Has anybody ever seen anything like this or have any suggestions?
I had this. I referenced assemblies whose "Target Framework" were set to ".Net Framework 4" in the "Application" secion of the projects properties. I changed this to ".Net Framework 4.5" not just in the referenced assembly's project but also the project I was building and it worked. Give this a try.
I have found this is a known problem with VS2012. Check to see how you are building, 64 bit or 32 bit. It won't work with 64 bit but it will with 32 bit. It will say things are missing and design will not work, however the program will run fine. I have heard the new VS update that hasn't been released yet will fix it.
Manually delete all the references to the libraries of the other projects and re-add. Intellisense rebuilds whatever it needs at that point and doing this has helped me in the past.
Another source of this problem is a solution with multiple projects containing code for the same namespace. The compiler can handle this. Intellisense won’t.
Related to a couple other answers here, I had a "Data" project using a "Data" namespace. Built fine, but just started recently showing errors from intellisense (even though it continued building fine.) (VS 2015.)
I fixed this by changing my "Data" project and namespace to "MyCompany.Data".
Oddly, the problem didn't seem to show up until recently, but making the change did fix it. Presumably there was a conflict in namespace with another project or reference, which can build fine, but intellisense can't handle.
You can change this in the Application tab of Project properties. You can also open up an EDMX diagram, right click, choose model browser, choose the second collapsable item in the model browser tab, hit properties, and there you'll find the Namespace option for generated Entity Framework entities and contexts. (Similiarly, if you modify an Entity Framework Model's namespace, you might also need to change the related connection to match [in Web.Config for ASP.Net and MVC.])
Make sure that there is no class with the name same as Project default namespace.
make sure that you don't reference .net framework 4.5 projects in .net 4 projects!
Examine your .proj files in a text editor and make sure the paths to your references are correct.
This can also happen if you set the Build Action to "None" on the referenced file and forget about it.
I had the same problem, where it would build and run fine, it just would always show that error and I couldn't use intellisense with the class.
I actually used the automatic method of creating the class in a new file to resolve the issue, then just copied the code over from the real class. I deleted the old file, renamed the new file, and now it works.

Reference disappear upon debug/build (C#, VB.NET, VS2010)

I am using the MagicLibrary for a few components. I knew it was written in Visual Studio 2003 and recompiled it in Visual C# Express 2010. It compiled just fine and I could see the library in the folder.
I then created a new project in Visual C# Express 2010 and added the components MagicalLocalLibrary.dll to the Toolbox. They appeared fine with no errors. I put in a control from the Toolbox to my form, and it seemed fine. I then debugged (to see if any errors would occur) and I saw that the reference MagicalLibrary disappeared and I got the error:
The type or namespace name 'Crownwood' could not be found (are you missing a using directive or an assembly reference?)
The thing is that, the reference shows fine under References in Solution Explorer but I can't import it with using or use it in the code (simply is not listed in InstelliSense either) but if i go into the Object Browser and choose "My Solution" it is not listed. I can click on the Reference in Solution Explorer and just change the Copy Local property to True or False, then it will appear in the Object Browser but whenever I debug my project again it disappear.
Any idea why it does this? Thanks in advance.
Check that you are using the .Net 4 framework and not the client profile version
You find that setting when you right-click on your project, choose properties. And under application there is a setting for target framework. If you have chosen the .Net 4 framework Client Profile, then this behavior that you described can happen
I ran into a very similar issue once. In my case the problem turned out to be a missing dependency for the "vanishing" namespace's assembly. What finally gave me the information I needed was the suggestion in this StackOverflow answer to raise the MSBuild output verbosity level. After raising the verbosity setting the IDE should give you a more specific reason why the compilation fails.

WinForm designer error open designer

I work on VS 2010 .net 4.0 , my app had winForm with many controls.
sometime i occur very starnge designer error:
Could not find type 'Namespace.TypeName'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.
The variable 'ControlName' is either undeclared or was never assigned.
i click Ignore and Continue the control disappear from my form.
if i look in designer.cs the controls are exists..
I read this : link text but it is in vs2003 and i can not sucess solve this problem..
Thanks..
This problem can be caused in a number of ways, usually by custom controls/components that:
Do not have a default constructor
Depend on variables that are set at run-time (singleton instances, data sources, etc)
Fail to compile (you can't use a control in the designer until it compiles successfully)
Have been significantly changed/rewritten since they were added to the form
It can also happen as a result of a glitch in Visual Studio - this is much rarer, but can usually be fixed by cleaning and rebuilding your solution and/or restarting the IDE.

Visual Studio Designer broken using Expression Blend SDK Behavior

I'm running into a problem with the new Expression Blend behaviors.
I have a customized Behavior<T> class developed using the Expression Blend 3 SDK.
The behavior works properly, and the solution compiles. That is perfect. I have all of my references (System.Windows.Interactivity.dll + Microsoft.Expression.Interactions.dll) setup in my projects that reference the behavior.
In addition, as I mentioned, Visual Studio compiles the project fine.
However, if I load the XAML file in the Visual Studio designer, I get the following error after the solution compiles:
Error 1 The attachable property 'Behaviors' was not found in type 'Interaction'. C:\Path\To\MyFile.xaml 19 14 MyApplication
That line of the file is the first line of the following:
<Interactivity:Interaction.Behaviors>
<Behaviors:DoubleTextBoxBehavior />
</Interactivity:Interaction.Behaviors>
My window reference is setup with:
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
I've even eliminated my custom behavior as a possibility. I can just include the following line, and "break" the designer:
<Interactivity:Interaction.Behaviors />
As far as I can tell, this should work. There shouldn't be an error. The compiler handles this fine, but Visual Studio won't load this in the designer any time I add the behavior line.
Does anybody have an idea of what can cause this, and how to fix it?
Edit:
I've done some more testing, and this appears to be an error occurring only within the Windows Presentation Foundation Designer windows within Visual Studio 2008 (with sp1). The project works fine, and no error is reported, provided I only use the XML editor. If I open this in the Designer, however, it reports the error and shows a Problem Loading designer.
The error does not appear unless the XAML file is opened in the VS designer.
This is due to known issue in Visual Studio, and is addressed by a hotfix: KB958017.
This can be corrected by downloading and installing the KB958017 Rollup Fixes for Visual Studio Designer.
I've tried to reproduce your issue, but I couldn't. I have created the following WPF application:
<Window x:Class="WpfBehaviorsTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Title="Window1" Height="300" Width="300">
<Grid>
<Interactivity:Interaction.Behaviors/>
</Grid>
</Window>
Everything works just fine before and after I compile my project. Could you test if this works for you? What version of MS Blend SDK do you use? What version of Visual Studio? Just to be sure: we speak about WPF application, not Silverlight, correct?
Update:
You have exactly the same configuration as I do. The only problem is that it works here, but doesn't work on your side. Let's squash this insect by the following checks:
What version of "System.Windows.Interactivity" assembly get's loaded by designer? You could run another instance of MS Visual Studio and attach to the first VS process with "buggy"-designer. Go to Debug->Windows->Modules and check the version of System.Windows.Interactivity.dll. If it looks good you still can go and double check it with Reflector. Does it has Interaction class? Is there BehaviorsProperty in it?
What exactly is happening there inside? If assembly that we've checked in step 1 is correct, let's run heavy artillery. In fact I effectively use this approach quite often, whenever I have VS/Blend designer issues. Just run another instance of Visual Studio. Turn on breaks on all CLR exceptions (Debug -> Exceptions-> Check the box after CLR Exceptions). It might also help to turn on .NET source code debugging. Attach to the instance with invalid designer. Reload designer. Now, instead of seeing confusing message, attached Studio will bring us to the very heart of the Exception. What's there?
I am using VS2010 and I experienced the same problem but found a solution.
I had a two projects in my solution. Project "A" that used the Behaviors in a silverlight control (defined in the xaml). I then referenced the control in project "A" inside the active silverlight project "B" which was being executed. I kept getting the error The attachable property 'Behaviors' was not found in type 'Interaction'
When I added the System.Windows.Interactivity reference to project "B" it fixed my runtime error.
I am not sure why that reference was not being loaded because it was being utilized by the control from project "A" but it wasn't. Oh well.

Categories