UWP: Error when referencing Views from seperate repo - xaml

I have a normal UWP project but I've broken the Application, Views, ViewModels, Models, etc. into their own repositories.
When I reference the View (Page) from the Views repository I get an error |An unhandled exception of type 'System.AccessViolationException'".
If I make the view in the Application level of the project I don't get the error. My repository is a class library and all are pointing to the same Windows 10 version.
Can anyone explain this?

So, a colleague of mine actually found the answer for me. It's more of a hack but it works. I can't explain definitely why this works but I have an assumption. I'll leave the assumption to myself....
To make this work, open your App.xaml file and add the namespace to the Views repository.
xmlns:Views="using:Views"
Then make a dummy resource to the main view in that repository (or any view I'm assuming.)
<Application.Resources>
<Views:MainPage x:Key="mainPage" />
</Application.Resources>
For some reason this makes everything work like a charm... I know it's a hack but it's simple and clean enough that I've bought it and moved on.

Related

How do I get rid of these inexplicable design-time errors in an empty App.xaml?

I have an issue with App.xaml in a Silverlight 5 application project. Basically, I can remove everything (resources inside <Application.Resources>, such as styles and converters) from it, until I am left with only this:
<Application x:Class="SomeProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</Application>
But Visual Studio 2013's Error List window will still list below three (ignorable) design-time errors:
The property "Resources" can only be set once. (App.xaml, Line 1, Column 1)
The "Key" attribute can only be used on an element that is contained in "IDictionary". (App.xaml, Line 1, Column 1)
The specified value cannot be assigned. The following type was expected: "ResourceDictionary". (App.xaml, Line 1, Column 1)
These are purely design-time errors; I can successfully compile and run the project. However, the errors don't make any sense, and they are annoying.
Does anyone know how to get rid of them?
Some things I've tried already:
Cleaning and rebuilding the whole solution.
Manually wiping the App.g.i.* files in the obj artifact directory.
Manually deleting the obj and bin directories.
I made sure that App.xaml is in the main Silverlight application project (not in some other class library); and there is no other project item of type "ApplicationDefinition".
Ah the joys of Silverlight development... While I don't have a completely competent technical answer to your question, I've found that restarting your machine can do magical things (I know, no true developer ever wants to hear the word "magical" in a fix) but one could assume there's a caching issue somewhere...
However the point is restarting can often clear up erroneous errors related to build time resources that you would normally expect a quick clean to fix.
Anyhow, glad you got a remedy. Cheers!

mogenerator doesn't generate the files

I've just installed mogenerator using one of tutorials. I have added run script to my new target, and clicked Cmd+B. I should get some new files, but i didn't. In my .xcdatamodeld i have 2 entities (User and Repos). Below you can find my print screen of my project.
Where is the problem in my thinking? What should i do more? Please, help me, because i haven't found the solution on the web yet.
This all looks fine (judging by your screenshot).
One thing to check - which caused me the same issue - is that, when you've created your Entities in the xcdatamodelId file, make sure that you click on the Data Model Inspector icon, and that each entity has a Name value, and a matching "Class" value.
Miss out the Class name, and nothing will get generated.
Btw, when you click on Build, do you get a "Build succeeded" message ?
Here's the tutorial I followed to get mogenerator working:
RaptureInVenice
I should say, I've used mogenerator in a few projects, and this command line bit is always the piece that gives me trouble. Sometimes, I have to select my xcdatamodelId file, and create a new Version of it, before mogenerator will use it. But once it is working, it's a blessing.
Anything to avoid having to use the needlessly over-complicated CoreData stuff.
Someone should remind Apple that it's 2014...

adding dll to C# project

I have created dll out of a c# project say "a.dll", this project has some UIs with Charm Flyouts.
now i am adding this dll into another C# project say "b",so that i can see the Charm Flyouts
in the "b" project. but i am not able to see the Flyouts , I don't know what exactly the problem is. For sake i changed the Page name as i thought there may be some conflict between
page name as both the projects have same page name as MainPage.
Please help me to do this,thanks.
Not sure if this is it, but I've ran into a somewhat similar problem with images from ProjectA, where I want them to be shown in ProjectB. This however is not possible in Store Projects, the image should be in the same project and cannot be referenced from ProjectB to ProjectA (without returning any error).
A workaround (if possible) would be to put the two projects in the same solution and add the charm flyouts (if they are images) as linked items in ProjectB...
Hope this gets you towards a solution.

Xcode error when ctrl-dragging image to new class

I already asked this in the Apple Dev Forum but received no replies, so I'll try here.
I'm unsure if this is a bug or whether I've missed something since I'm still very new to programming.
I have multiple view controllers and have made multiple classes. I have set the custom class "bit" of each view controller to the revelent class. When I ctrl-drag anything from the view to the relevent class header, I get the usual pop-up. I fill in the info, press connect, and BAM. It does the same kind of error whether I choose "Outlet" or "Action" It worked in the previous Xcode but I'm not sure if I've forgotten something.
The view controller and class that I added with Xcode 4 is still working beatifully.
I've tried adding the image manually but all that gave me was a SIGBART error just trying to get to the view. Again, I may have missed something, but I don't think there's much to miss is there?
Any help would be appreciated.
Just to eliminate a few things... I've deleted derived data, restarted Xcode and done a "clean". That's all I can remember that I've done.
Problem solved:
When selecting the implementation file. When I looked in the File Inspector, I found that under "Target Membership", the app name wasn't ticked. I ticked it and it now works well.
Since I didn't need to do that in Xcode 4, I suspect in Xcode 5, it doesn't do that automatically. Maybe that's a bug? I don't know if it was deliberate by Apple, but I think I'll file a bug report anyway since It's a bit of a nuisance.

How to find out what the first view controller that gets loaded in an iPhone app is?

I think that looking at others' code is a good way to learn. I'm trying to learn iOS programming like this, but one thing that's confusing is when I look at a new project there's always a bunch of view controllers, and I don't know which one loads first.
Is there an entry in the plist file which says which view controller gets loaded first? How do you go about picking apart someone else's code in an Xcode project?
In the project there's a space called Main Interface / Main Storyboard that looks like this:
Target > General > Deployment Info > Main Interface:
But if they set it in code, then use ⇧+⌘+F on the project and search for 'rootViewController'.