The tag 'XXX' does not exist in XML namespace 'clr-namespace:YYY' - wpf

I have implemented a converter to convert Int32 to String to be able to binding a property to a textBox.
I implement this converter in the namespace MyApp.Converters and it is called Int32ToStringConverter.
Then, in my axml I add the reference to my converter as follow:
<Window x:Class="MusicaDB.Views.PrincipalView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
**xmlns:converter="clr-namesapce:MyApp.Converters, aseembly=MyApp**">
Later, in windows.Resources I have:
<Window.Resources>
<**converter:Int32ToStringConverter** x:Key="Int32ToStringConverter" />
</Window.Resources>
I get the error that the tag Int32ToString converter does not exist in the namespace MyApp.Converters,assembly=MyApp.
I have the project in the local hard drive, in the project properties, the destination .NET is framework 4.0, not framework 4.0 client profile and I try to clear the solution and recompile but the problem persists.
Mainly, this is the two solutions that I always find, but don't resolve my problem.

Three fixes to make here:
No spaces -> xmlns:converter="clr-namesapce:MyApp.Converters,aseembly=MyApp"
No misspellings -> xmlns:converter="clr-namespace:MyApp.Converters,assembly=MyApp"
Right delimiters -> xmlns:converter="clr-namespace:MyApp.Converters;assembly=MyApp"
From the the documentation:
Note that the character separating the clr-namespace token from its value is a colon (:) whereas the character separating the assembly token from its value is an equals sign (=). The character to use between these two tokens is a semicolon. Also, do not include any whitespace anywhere in the declaration.

Another possible solution to this problem is that you're not using the same version of .Net in your project and your library.

I am exploring as to why this is happening, but if your converter is in the main assembly, removing the assembly= from your xmlns:converters tag should remove that build error.

For the record ...
I've face a similar problem and if I removed the ";assembly=X" part from the XAML it worked fine
But don't really understand the reason.
As suggested in this blog:
http://zoomicon.wordpress.com/2012/07/02/fix-the-tag-xxx-does-not-exist-in-xml-namespace-clr-namespaceyyy/#comment-7761

I see two possible causes. The first is that you misspelled "assembly" as "aseembly" in the first starred line. Changing the spelling might be enough. The second possibility is that you haven't added MyApp.dll to your project references, which appear like this
in Visual Studio.

All answers are right. And after trying all of them and you cannot configure why its happening, everything seems alright, Please restart the Visual studio.
That worked for me after wasting almost 1 hour. I found everything ok, but restarted the VS with administration.

use the assemble tag only if it is in another project.
other wise use just namespace tag alone.
For me this fixed the issue

In my situation, I had the same problem with xmlns:local="clr-namespace:<mydefaultnamespace>".
I solved this changing the order of the includes. I put it first and all was solved.
A strange behaviour, but this was my workaround that I found in my situation.

In my case, the assembly which contained the namespace was not physically there.
I checked the references of the assembly that had the build error and looked at the properties of the referenced assembly in question.
I navigated to the path and discovered the assembly was indeed missing (which I realised was my own doing), giving rise to the misleading error.

There is one very obscure case when you get this error - if you're using Microsoft.mshtml.dll and you upgrade to Windows 10 anniversary edition, or as it turns out the Creator edition too.
Even if this isn't what happens to you make sure the library containing the component that cannot be found can be fully compiled. Look in the error list (not the grid but the Output console) for any clues.
In my case I was using Microsoft.mshtml.dll as part of an HTML editor and it was unregistered somehow (in the GAC).
The following article explains with screenshots:
https://techninotes.blogspot.com/2016/08/fixing-cannot-find-wrapper-assembly-for.html#comment-form
In short I had to run a Visual Studio command prompt (as admin) run these commands:
cd C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a
regasm Microsoft.mshtml.dll
I did say obscure :-) The important point is to read the errors that may be buried amongst all your warnings because there might be an important clue.
This can be especially confusing if an Operating system update suddenly breaks your project.

I was temporarily replacing a NuGet dll with a local one when this happened. Turned out the assembly was not the same version as the one I was replacing. I built my assembly with the correct version and it worked.

Related

max-pool-size is invalid in combination with derive-size

For the last couple of days I’ve been battling with an issue which I believe is derived from a change in the source code in Thorntail and unfortunately this code doesn’t appear to be publically available.
The error I’ve been receiving is this:
"WFLYCTL0105: max-pool-size is invalid in combination with derive-size".
Previously you could just leave a “derive-size” out of the configuration and there wasn’t an issue however now anytime I’ve included the “max-pool-size” no matter what the combination with “derive-size” it fails with the above mentioned error.
From the latest Thorntail dococumentation:
Specifies if and what the max pool size should be derived from. An
undefined value (or the deprecated value 'none' which is converted to
undefined) indicates that the explicit value of max-pool-size should
be used.
This is what I had previously in WildFly project-defaults.yml which worked perfectly fine:
ejb3:
default-resource-adapter-name: activemq-rar.rar
default-mdb-instance-pool: mdb-strict-max-pool
strict-max-bean-instance-pools:
mdb-strict-max-pool:
max-pool-size: 1
Any ideas or examples would be greatly appreciated.
More information added in response to questions:
The project was updated from using WildFly Swarm 2018.4.1 to use Thorntail 2.2.0.Final.
The code that appears to have changed in Thorntail is below:
OLD code:
https://github.com/stuartwdouglas/wildfly-swarm-core/blob/master/ejb/api/src/main/java/org/wildfly/swarm/ejb/EJBFraction.java
.strictMaxBeanInstancePool(new StrictMaxBeanInstancePool("mdb-strict-max-pool").maxPoolSize(20).timeout(5L).timeoutUnit(StrictMaxBeanInstancePool.TimeoutUnit.MINUTES))
New Code:
https://github.com/thorntail/thorntail/blob/802e785fdd515ecc1b52b22a64a6ff9338dace29/fractions/javaee/ejb/src/main/java/org/wildfly/swarm/ejb/EJBFraction.java
.strictMaxBeanInstancePool(new StrictMaxBeanInstancePool("mdb-strict-max-pool").deriveSize(StrictMaxBeanInstancePool.DeriveSize.FROM_CPU_COUNT).timeout(5L).timeoutUnit(StrictMaxBeanInstancePool.TimeoutUnit.MINUTES))
If anyone has a link to the above source code that would be great. The only links I can find appear to be from JBOSS so the code looks like it was ported accross and not made publicly avaiable.
After the question update: the default configuration of a couple of fractions was changed to better align with default configuration in WildFly 11. You can configure derive-size: null and then the max-pool-size should take effect.
Something like:
ejb3:
default-resource-adapter-name: activemq-rar.rar
default-mdb-instance-pool: mdb-strict-max-pool
strict-max-bean-instance-pools:
mdb-strict-max-pool:
derive-size: null
max-pool-size: 1
(Note: previously, this answer recommended setting derive-size: none, but that doesn't work. After the discussion in comments, I changed the answer to recommend derive-size: null, which does work.)

To solve warning 'is never used' in WPF

I have declared an event in "Question" class as:
public event SectionAffected OnSectionAffected;
I have not used this event in the entire class.But I have used it in another class as:
Question.OnSectionAffected += new Question.SectionAffected(ResetDependentSection);
I am getting warning as:
The event 'QuestionManager.OnSectionAffected' is never used in Question class.
How to solve this warning?
A warning is just that... a warning. Having warnings is not necessarily a bad thing. However, if you really want to remove it, you can specify that in Visual Studio. If you open the relevant project's property page (by pressing ALT + Enter when the project is focused), turn to the Build tab. Click the RadioButton named Specific warnings and enter the specific error code(s) that you want to supress in a comma separated list. You can find out more from the How to: Suppress Compiler Warnings page on MSDN.
UPDATE >>>
I believe that you are looking for the numerical error code number... for this, you should look in the Output Window of Visual Studio. If you don't already use this window when writing WPF, then I would strongly advise you to do so. However, these codes are not always shown in this window.
As an alternative, you can find descriptions and error codes in the C# Compiler Errors and Code Analysis for Managed Code Warnings pages on MSDN.
UPDATE 2 >>>
After doing a quick search online (which is really what you should have done), I found this page which seems about right: Compiler Warning (level 3) CS0219

Could not insert new outlet connection [duplicate]

This question already has answers here:
Xcode 4: Creating a UIView xib, not properly connecting
(33 answers)
Closed 9 years ago.
Could not insert new outlet connection: Could not find any information for the class and not showing any class named "ViewController"
Solutions I have done :
- Restarted XCode
- Restarted System
- Deleted the Deriveddata contents from /Library/developer/xcode
But nothing worked for me
Here is the screenshot for the error
I got the same problem as you today... I think this is a bug of Xcode, below is the way to fix the issue:
Close the project you are working on with.
Delete your project's【DerivedData】folder. (This folder may inside your project's folder, or inside ~/Library/Developer/Xcode/DerivedData/(your project)/ ) or somewhere else that was setup by you.
restart your project.
After these steps, the problem should be solved. And from my experience, these steps can solve many Xcode problems, so if you got some problem with Xcode again, try these steps first.
Removing(removing reference, not deleting) and then adding the appropriate file(the file of class you want to add the outlet to) is actually enough.
Edit 1 I found that after unchecking (in XCode 6.3.1) I had to wait a few seconds for the Indexing to appear and complete in the project name box. Same for the way backwards. This increased chances to fix the issue in almost all (but not all) cases.
Edit 2
Removing reference means that You do not delete the file completely but just remove it from the project (it still exist in the folder of your project, you add it later).
That's most often a problem of file indexing.
To fix it try to clean your target and if this doesn't work, go to your Derived Datafolder and delete your application there.
This will force xCode to reindex the files
Just got the same issue on Xcode 4.6.2.
Tried solutions presented in different answers/comments, but it still didn't work.
Then all I did was to just:
save all my work;
just quit Xcode & load it again;
then I was able to insert the new outlet connection successfully.
Hope this will save some time/frustration for somebody else.
Personally, I had the same problem: "could not insert new outlet connection" AND when I was starting typing something like "UI..." XCode wasn't doing anything.
I searched for answers, I tried several things... but it was just an unchecked box. When I was creating a new class, XCode unchecked the box linking the class to the project (I guess).
I can't post a screen shot because I don't have 10 reputations but when you create your class, XCode asks you where you want to save it. Down the finder window, you have 'Targets' and two boxes: 'YouProjectName' and 'YouProjectNameTests'. You should check the first one (at least).
Hope this will help. I saw different discussions about the subject.
I recently came across this problem. I soon realized that the cause had been my own doing. I had previously disabled XCode indexing (which used to take forever & eat up my RAM), using the below code in a terminal window:
defaults write com.apple.dt.XCode IDEIndexDisable 1
To revert XCode to its default state, i used the following line in a terminal window:
defaults write com.apple.dt.XCode IDEIndexDisable 0
Voila! All's well again..
If you've imported the Class into your Xcode Project you have to manually add the Class (.m file) to your 'Compile Sources'.
Select project icon > TARGETS > Build Phases > Compile Sources
Click the + button and add your *.m file.
Finally I did it by removing the xcode completely from my mac and reinstall the xocde.dmg file and then install MobileDevice.pkg and MobileDeviceDevelopment.pkg residing on /Applications/Xcode.app/Contents/Resources/Packages
make sure that your source have had been included in the "Build Phases" place.
This do fix my problem. But I think Xcode is still really buggy and annoying.

At design time pack uri is valid, but not at runtime?

I'm setting a Button's content to an Image. It looks something like this:
<Button>
<Image Source="pack://application:,,,/NavigationImages/nav_up_left.png" />
</Button>
In my project I have a subfolder named NavigationImages and within that folder is the image file nav_up_left.png.
When I view the Designer the image appears, however during runtime I get an IOException error saying it cannot locate the resource.
The Build Action is set to Resource.
Actually, this worked fine in one project. But when I copied it over the another project it fails. This seems like an incredibly simple problem, but I find myself stumped and ready to start pulling out hair. #_#
Your thoughts and suggestions will be much appreciated!
Whelp, I figured it out...kinda.
I copied that xaml code from one project where the output type is Windows Application, to another project where the output type is Class Library.
I didn't think of it at the time, but apparently when the output type is a Class Library the pack URI needs to change.
So instead of "pack://application:,,,/NavigationImages/nav_up_left.png" I changed it to "/ProjectName;component/NavigationImages/nav_up_left.png" and now it's working just fine.
I'm not 100% clear why this is works and not the former. I've read through the MSDN documentation on pack URIs in WPF but perhaps I misinterpreted something.
I'll leave this answer unchecked in the event someone can give me a good explanation why what I previously had doesn't work in a project with output type Class Library.
I'm probably missing something really simple. #_#
I just struggled with this same problem for quite a while, and I think that part of what was going wrong in the original was the missing word "component". I, for instance, had
myBitmapImage.UriSource = new Uri(#"pack://application:,,,/MyApp;images/mona2.jpg");
but should have had
... = new Uri(#"pack://application:,,,/MyApp;component/images/mona2.jpg");
The word "component" is not part of the pathname, despite its appearance -- it's a string literal that has to be there. Why? Someone thought it'd be a good idea, I guess.
And for those struggling with another part of the thing, what about "MyApp"? That's the name of the Assembly. Right-click on your project name, select "Properties...", and under the "Application" tab you'll see the "Assembly name:" field.
If you don't feel like searching for that (or worry that it might change, breaking your code), you can do this:
String appUri = #"pack://application:,,,/" +
System.Reflection.Assembly.GetEntryAssembly().GetName().Name + ";";
String path = appUri + "component/images/mona2.jpg";
myBitmapImage.UriSource = new Uri(path);
Not very pretty code, I admit -- it can clearly be shortened -- but it'll gets you where you need to go, I hope. Remember to set the "Build" property on your image file to "Resource"!
Just to shine a light on what was happening in your situation. The second pack uri. The one that worked. Is meant for resources located in an assembly other than the host application. By the sounds of it, the host application was loading this resource from the Class Library in question?
You can see the differences in the pack uri schemes here:
MSDN Pack URI Scheme
The uri changes slightly when referencing a resource from the main assembly, and referencing one from another assembly.
Also, the pack://application:,,, includes what is referred to as the "authority", to omit it would basically make it a relative path, both are valid in most cases where the application authority is assumed.
EDIT: basically because /Subfolder/Resource.xaml(.jpg etc.) and /Assembly;component/Resource.xaml are very similar, the latter tells the parser/loader that it's looking in a referenced assembly, not in the main application's assembly. (I imagine this helps speed up the search).
One other solution to getting this right:
Once your image Build Action is set to 'Resource' and you have rebuilt, navigate to the properties of your <Image /> object. The properties window will provide a ... file resource browser, whereupon selecting your image the Source="..." attribute of your <Image /> will be correctly filled in.

Warnings and errors (CS0436, CS0234) when creating user controls composed of other user controls in the same project

I'm working on a Windows Forms solution with many winform ui projects.
There is a class library project that contains some custom shared controls, named MyControls.
Now, when I create a control in MyControls
that is composed of one or more controls in the same project, I run into problems.
I either get compilation warnings: warning CS0436: The type 'MyType' in 'path-to\MyType.cs' conflicts with the imported type 'MyType' in 'MyControls.dll'. Using the type defined in 'path-to\MyType.cs'. Or I get a bunch of different compilation errors, all pointing to "MyControls.dll" (error CS0234 - "are you missing an assembly reference?").
I get either the errors, or the warnings, never both.
How to solve this?
Note
I added visual-studio-2010 because that's the version I experienced the problems with. No idea if this relates to other versions too.
I found that Visual Studio adds a self-reference to MyControls when I drop a control from the MyControls project on another control in MyControls:
<Reference Include="MyControls, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
My current work-around is to manually delete this reference from the MyControls.csproj using a text editor.
When I've done this, everything works fine, until I drop another control that triggers a self reference.
Better solutions are appreciated!
you can make a small and "legal" change in your solution and get the "legal" solution... lets say your project name is: "project01"
go to references folder in your project - one of your references called "project01" - just remove it...
the the warning is very fair! you design a form and in the other hand import your project as a reference!
I know this thread is a bit old, but I just went looking for a solution to this issue, and it seems that MS doesn't have anything other than what Marijn suggested earlier:
https://connect.microsoft.com/VisualStudio/feedback/details/613502/automatically-add-self-reference
Hopefully it's fixed in VS 2012.

Resources