Bind data from source under xaml designer - visual-studio

I am using a split page view for one of my page layouts in my Windows 8 app. If I run the app in debug mode the source details are loaded and everything is fine.
However, in my XAML designer view I am unable to bind the data to the view using d:Source & d:DataContext even though I've defined the xmlns:data source.
The error I get is as follows: The name "MyDataSource" does not exist in the namespace "using:MyApp.Data"
Has anyone come across this before?

I figured it out in the end. Rookie mistake, I used the incorrect namespace. Instead of MyApp.Data, I used just MyData in defining the source file namespace model.

Related

Adding image to Xaml button breaks Xamarin app, but Visual Studio gives no error message

In Xaml, I'm trying to make an image do something when tapped (I'm testing it on Android). The Image tag of the Button class seems to be exactly what I need, but the following code breaks my application:
<Button Clicked="OnListClicked" Image="chimp.jpg"/>
Even though it works fine when I remove the Image tag. I could probably figure out what's wrong if I had an error message, but all that is shown is:
Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code).
I've had issues with my Xaml code before, and I would get the same message. I'm confused though...my Xaml isn't external, is it? It's just a Xaml file inside my shared project, like any other file.
Under Exception Settings, I have every single box checked, and I also added XamlCompilation:
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace MyApp
{...
so I'm not sure what else I can do to start getting error messages. And I'm using Image in exactly the syntax described in the documentation, so I'm not sure what could be the issue with my Xaml. Anyone have any thoughts about any of this?
The reason I wasn't getting a specific error message was that I was actually navigating to the page with the errors from another page. When I set the page with errors to my root page, I started getting error messages again.
Apparently, my runtime's memory was running out before it could render the image. I had noticed before that my app was limited to five images: any images after the fifth one simply didn't show up. I've never gotten an error for it, though. Perhaps since this time it was a button, it "needs" to be displayed for normal functioning, and that's why it's throwing an error this time?
Either way, I just removed images until there were only 5, including the button image, and now it displays without issue. I'm not sure if this is expected behavior, though. I don't see why my runtime wouldn't be able to handle more than 5 images.

How to restore working solution?

I was working on a C# project and everything works perfectly fine. But after I messed up with a code a little now its getting a wired error. But I can run the last working solution fine. Can I reset the code again to last working solution? If I can, what is the method to do that?
Here is the error message:
"Error 1 'Static_calc.Form2' does not contain a definition for
'Form2_Load' and no extension method 'Form2_Load' accepting a first
argument of type 'Static_calc.Form2' could be found (are you missing a
using directive or an assembly reference?)"
That sounds like you have deleted a method that your form is rely on in its designer code behind. Take a look in the designer file for Form2 for any event bindings that relate to Form2_Load and delete the line that mentions it.
You should then be able to view the form correctly in the gui and use it as before.

Fail to load assembly on a MVC View

Some Context
I have one closed source asp.net MVC application distributed for several customers. I'm trying to develop a extension to include some very specific functionalities that will be used by a single customer (he will also have the extension source code).
I'm developing the extension as another mvc project, loaded as an area. I'm trying to avoid having to deploy the extension binaries in the main application '/bin' folder.
I'm loading the extension assembly and it's dependencies manually in the PreApplicationStartMethod of the main application assembly. The area registration process went fine and the area routes are registered as intended.
The Problem
When I try to load some extension pages, I got a "The view 'xx' or its master was not found or no view engine supports the searched locations." message. I investigated I little and replaced the view contents with a 'Hello' string. The view was rendered correctly.
I tried to produce a minimal that triggers the error and turns out it's the '#model'directive. I tried to figure out what's happening and It's an assembly loading error. I created a minimal view with '#model object' and tried to cast the Model to original type and got the following error message: "Could not load file or assembly 'xxx' or one of its dependencies. The system cannot find the file specified." (this assembly contains the class type used by the view)
Just to confirm the issue, I moved the mentioned assembly to the main application '/bin' folder and everything worked.
I also inserted some model manipulation instructions on the controller, just to investigate if an exception will appear but everything went fine, I could even render a grid using json.
I'm loading every assemly with:
var assembly = Assembly.LoadFrom(file)
BuildManager.AddReferencedAssembly(assembly)
There's something extra I need to do ?
Needed to add the assembly private path
AppDomain.CurrentDomain.AppendPrivatePath(pluginFolder);
Don't know the real explanation for it but I guess it's relates to the use of Assembly.LoadFrom(file) instead of Assembly.Load() and the fact that views are compiled later.

Running ASP.NET on Mono Resource Access Errors

Summary of Solutons: The core issue was that I had my resx files in subfolders within App_LocalResources and App_GlobalResources. Separating things into folders is fine on .NET but Mono only looks at the files in those folders ignoring any sub folders.
Issue #2 works only at runtime. In other words the Resources namespace can be used in the aspx or in code in a script block in the page but not in the code behind. It seems that I've never used the Resources namespace in the code-behind proper so all 3 of my issues are solved.
I have an ASP.NET application I was previously working on on .NET on a PC and am trying to move over to a Mac to develop using Mono and MonoDevelop. The application utilizes the App_GlobalResources and App_LocalResources folders. The application worked on .NET but does not function properly on Mono as I will outline. The version information is below:
OS: Mac OS 10.8.2
Mono: 2.10.9
ASP.NET: 4.0.30319.1
MonoDevelop: 3.0.5
I've tagged this with MonoDevelop because I'm not sure what server is being used and whether it is a part of MonoDevelop or Mono itself or is separate. I'm not familiar enough yet with Mono and it's parts...
The issues I'm having revolve around accessing resources and I'm having various related issues which I'll outline below:
Issue 1: meta:resourcekey doesn't work and "a resource object was not found at the specified virtualPath." error
I have App_LocalResources folders and resx files for each page at the root of the application as well as in sub-folders where page localization is required. Elements on the page that have a meta:resourcekey attribute do not have the relevant property assigned the value in the resx file.
So for example I have: /Site/Home.aspx with a /Site/App_LocalResources/Home folder which contains home.aspx.resx and related translations
N.B. as I was writing this I realised the names don't match up with regards the files case, but that is not the issue, I've tested with another page in the same folder and it doesn't render out the resource values.
The page in question has no code behind.
A different page in the root of the application called PageNotFound.aspx has related resx files in /App_LocalResources/PageNotFound/PageNotFound.aspx.resx
This page content is basically as follows (if I remove both the page renders)
<h2><asp:Literal runat="server" meta:resourcekey="PageNotFound" /></h2>
<% string message = GetLocalResourceObject("Sorry.Template").ToString(); %>
I get the same error whether I remove the first or the second of these lines. The error starts:
System.Resources.MissingManifestResourceException: A resource object was not
found at the specified virtualPath at
System.Web.Compilation.DefaultResourceProvider.GetLocalResourcesAssembly
If I remove the first line is actually builds and tries to render the page but crashes giving the above error.
If I remove the second line I get the error as well but it is while the page is being parsed and the runtime is trying to build the page class.
So for one page is seems build and run with meta:resourcekey attributes but isn't binding the resource value to the properties of the underlying controls, on another page it seems to crash trying to access the resources. The odd thing is the page that crashes is a very simple page without a master page and it basically only has the above content, the other page is quite complex with a master page and it renders (i.e. no parser error) but without the resourcekey values assigned....
The only differences that I can see are that one page is in the root directory and no master page, the other is in a sub folder and has a master page? Go figure! Any ideas?
Issue 2: Resources namespace doesn't exist
If I access a page that uses the 'Resources' namespaces that is available in .NET, I get a runtime compilation error, as in the app builds when compiled, but as the page is parsed and compiled it causes a (runtime) exception...
Compilation Error: CS0103: The name 'Resources' does not exist in the current context
The code would be in the code behind: (EDIT: The following line I think, was me testing, my code never uses this namespace in a code behind (compile time) class. Once the global resources functioned then the namespaces worked at runtime, but not in scenarios where the namespace needs to be verified at compile time as outlined in the summary at the top of the question)
msg.Subject = Resources.EmailResources.Request_SubjectLine
or in a script block in the aspx itself i.e.
<%= Resources.EmailResources.Request_SubjectLine %>
Neither of these types of access to the Resources namespace work. Why does this not work in Mono. Does the Mono framework not generate this stuff for us like .NET does? (I'm fairly sure this namespace hierarchy is generated by the ASP.NET framework on .NET and therefore wonder if this just has not been implemented in Mono?)
Issue 3: GetGlobalResourceObject(...) Call Returns Null
In the code-behind I have calls to GetGlobalResourceObject() which works on .NET, but when I run it on Mono my code is throwing an exception. For example:
hlContact.Text = GetGlobalResourceObject("CommonResources", "Contact").ToString();
My folder structures is:
App_GlobalResources > CommonResources > CommonResources.resx and the designer file (CommonResources.Designer.cs) is there.
The resx files are all marked with build action of "EmbeddedResource", "Do not copy" use the Custom Tool "GlobalResourceProxyGenerator" and have a resource ID that makes sense for each file. (i.e. .App_GlobalResources.CommonResources)
The issue is that GetGlobalResourceObject() returns null... It's not finding the CommonResources resource....
Note that Mono is constructing '*.resource' files in the folder with the resx files.
Issue #1
Apparently mono doesn't search subdirectories for resources, that is you must keep them directly in App_LocalResources or App_GlobalResources. See the relevant part in the mono source code (line 134). If searching subdirectories is an official feature, then this is a bug, and can be easily fixed by changing the aforementioned line.
Issue #2
Works fine here (on linux).
Issue #3
I don't know how exactly you are embedding the resources, a small test project would help. For the App_GlobalResources the framework compiles them at runtime and then GetGlobalResourceObject works fine too.

netbeans form loading issues

Error in loading component: [jDialog]->mainPanel->titleBar
cannot create instance of <qualified classname>
The component cannot be loaded.
Error in loading layout: [JDialog]->mainPanel->[layout]
Failed to initialize layout of this container
Errors occured in loading the form data. It is not recommended to use this form now in editable mode - data that could not be loaded would be lost after saving the form. Please go through the reported errors, try to fix them if possible, and open the form again. If you choose to open the form as View Only you may see which beans are missing.
recently moved a class that was being used in several forms but all the paths in both form and java files were updated to point to the new location. Anyone know what could cause an error like this?
Things I have tried: clean + build, removeing and re-adding all library jar files, making sure the title bar and the old version in SVN were identical except for the package changes. Doing the same comparison with their respective form files.
In the View menu there is an IDE log option that allowed me to see what was happening behind the scenes to cause this error.
custom code for the text of one of the labels was throwing an exception.

Resources