I have a Page class in a project A. I want to navigate to this page from my Universal windows project(say Project B) page. In UWP I am trying to achieve this using Frame.Navigate(typeof(Page_classA)), since NavigationService.Navigate(new Uri()) is obsolete in UWP.
But I get a Windows.UI.Xaml.Markup.XamlParseException in this case.
Is there any other way in UWP or metro Apps for navigating to a page in different assembly?
We can use Frame.Navigate(TypeName) method to navigate to a page in different assembly.
For example, we can create a Class Library(Universal Windows) named "ProjectA" and in this project add a new Page named "PageA". Then in this project's Properties page, check the "Generate library layout" option in the Build configuration.
In WinRT environment, the resources are no longer embedded in the assembly but are placed next to the dll as content. So we need to generate library layout so that we can reference the dll in other project conveniently.
After this, we can build the project and we will get following layout in "Debug" folder:
In ProjectA folder, it contains .xaml file and .xr.xml file:
When we get the library output files, we can copy them to anywhere and in the Universal Windows Project(Project B), we just need to add reference to the "ProjectA.dll" file. Visual Studio will automatically pick these files up and put them in the appx package when it builds the app.
And in Project B, we can use following code to navigate to PageA:
Frame.Navigate(typeof(ProjectA.PageA))
In your case, you get a Windows.UI.Xaml.Markup.XamlParseException, this may be that the .pri file is missing when you add the reference. Here is a similar case. So please check your library layout and make sure these resources are are placed next to the dll you referenced.
Related
I have a class library project which I am using in a UWP project. If I add any usercontrol xaml file in the class library and build it it builds fine. But the UWP project gives an error that it cannot find the .xr file.
Do I need to add the .xr file externally in any folder to my UWP project?
Yeah, for a class library with XAML files, if we want to reference the dll in other project, we need not only the dll itself but also the .xr.xaml file and some other files. Because in UWP environment, the resources are no longer embedded in the assembly but are placed next to the dll as content. See the similar case: How to add xbf files to visual studio project.
The files we need to reference like following:
ClassLibrary1(Class Library name) Folder
ClassLibrary1.xr.xml
UserControl.xaml (UserControl XAML file)
ClassLibrary1.dll
ClassLibrary1.pri
To get these files, we can check the "Generate library layout"
option in the Build configuration under the project's Properties page.
Then we can copy these files to anywhere and the UWP project just need to add reference to the ClassLibrary1.dll file in the Visual Studio, Visual Studio will automatically pick these files up and put them in the appx package when it builds the app.
I am new to Xcode and want to add and use framework which I have taken from internet but
when I add it to my products folder by right clicking on products and using add new files it
runs fine and when i use my project's project.app file on my mac or on any other mac it
gives me dyld error that the bundle image not find. And when I use bundle image in my
framework folder its give me ld error that bundle not found help please.
ld: framework not found SMS-Bundled
Command /Developer/usr/bin/clang failed with exit code 1
*updated
when i add my framework to framework folder now its giving me error at run time...
dyld: Library not loaded: #executable_path/../Frameworks/SMS-Bundled.framework/Versions/A/SMS-Bundled
Referenced from: /Users/usman/Library/Developer/Xcode/DerivedData/Serial_Tools-detoutxzbnjrngcuulrbgcasxmjs/Build/Products/Debug/Serial Tools.app/Contents/MacOS/Serial Tools
Reason: image not found
(In Finder)
Go to the folder where your custom framework is. copy the framework. Now go to your project's folder. Create a new folder called Frameworks, paste the custom framework inside this folder.
(In Xcode)
Drag the custom folder FROM finder to the Frameworks folder on the project explorer (where all the rest of the frameworks are)
Now select your project, go to Build Settings, scroll down to "Framework Search Paths" field, double click the value to open it, press the + to add a new path, write ./Frameworks as the new path.
From now on if you want to add other private/custom frameworks all you have to do is copy them into the created frameworks folder, and simply drag and drop it into the xcode frameworks folder. (You must drag it from the project framework folder in finder to the framework folder in xcode).
PD: You don't necessarily have to name this folder frameworks, it can be whatever, just make sure to change the Framework Search Paths accordingly.
In your project build setting, under "framework search paths" mention the path of the framework.
This will resolve your issue.
I am working on the Visual studio 2010. want to create a dll which contains icons just like shell32.dll. Can anyone guide me what I need to do.
Purpose : I just want my fav icons bind with one dll and keep in my root drive and customize me all folder icons and I just need it ot contain Dll thats it.
I have not idea what and all efforted is needed, I am ready to put how much effort is needed.
Any suggestion or comment is welcome.
I am not sure what detail is need so adding the picture of shell32.dll.
You can create a Resource-Only DLL.
From the link:
To create a resource-only DLL, you create a new Win32 DLL (non-MFC)
project and add your resources to the project.
Select Win32 Project in the New Project dialog box and specify a DLL project type in the Win32 Project Wizard.
Create a new resource script that contains the resources (such as a string or a menu) for the DLL and save the .rc file.
On the Project menu, click Add Existing Item, and then insert the new .rc file into the project.
Specify the /NOENTRY linker option. /NOENTRY prevents the linker from linking a reference to _main into the DLL; this option is
required to create a resource-only DLL.
Build the DLL.
I am trying to create and then add the dylib to a project.
I created it by using the "Cocoa-Library" template and setting the type to "Dynamic" (not sure if it should be dynamic or static...). Then I created a simple obj-c class called Test and wrote a method in it that prints out something to console.
I compiled and used the generated .dylib file and put it in another project. Now whenever I try to use it, I get this message on runtime"
dyld: Library not loaded: /usr/local/lib/TESTLib.dylib
Referenced from: /Users/***/Library/Developer/Xcode/DerivedData/TestingDYLIB-axmoocnxbwznoyerfogosumqufxc/Build/Products/Debug/TestingDYLIB.app/Contents/MacOS/TestingDYLIB
Reason: image not found
I also created a Copy File phase and set the destination to "Frameworks". I still get the same error.
What am I doing wrong?
The issue is not where Xcode is looking for the library at compile time, which is what Simon Whitaker's answer addresses.
The issue is that the application which uses the dylib cannot find it at runtime. When an application is built that uses a dynamic library, it copies the install_name of the dylib into the output binary.
Creating a copy files phase and copying the dylib to the Frameworks subdirectory of the app's bundle is the right thing do do.
However, you need to do an additional step. You need to compile the dynamic library with an install_name appropriate for a bundle app. By default, a dynamic library is created with an install_name of /usr/local/lib. The app can't find your library there because it doesn't exist. Even if you put the library there, your users certainly won't have it, so that would be the wrong solution.
The right solution is bundling the library with the app. To set the install name for the dynamic library, go into the dynamic library project and set the "Dynamic Library Install Name" option to: #executable_path/../Frameworks/libmydynamiclibrary.dylib
Xcode is looking in /usr/local/lib/ for the library. If the library is in another location, add that location to your Library Search Paths:
Select project file in Xcode 4
Select the target, then click the Build Settings tab
Make sure All is selected in the filter bar (not Basic)
Scroll down to the Search Paths section and you'll find Library Search Paths in there
I have a website solution that contains three different Silverlight 4 projects, and they all make use of the same Silverlight class library.
I have done this by creating a class library project within the solution, and referencing it from the other Silverlight projects.
BUT the class library is included in every one of the XAPs. The user could end up downloading the same class library multiple times.
How do I canvert the class library into a XAP that can be downloaded once, in the same way that an assembly is?
(And why isn't there a Silverlight Assembly project type in Visual Studio?)
You should use Assembly Caching - it's a way to leave dependent assemblies out of your xap file. Instead you need to deploy them with your xap file by placing them in a seperate zip file in the same folder.
In the properties window of your Silverlight application you can choose to enable Assembly Library Caching. That will automaticly generate a zip file for each cacheably assembly.
In the project References folder in Visual Studio, select the referenced dll that you don't want to be loaded again, and in the Properties window set its Copy Local property to false.