Reference problems when using custom controls within Exrin - xamarin.forms

Using the base Exrin template, I am unable to use custom controls.
As it stands now, the Droid/iOS projects reference the App/Bootstrapper project, so that seems like the correct place to put them, but when creating a new page or BaseView, I am not able to access the custom control's namespace because the View project does not reference the App/Bootstrapper project.
The Tesla sample app does not have this problem in its current implementation since there is no separation of the App/Bootstrapper and the View projects.
(1) Should a reference to the App/Bootstrapper be placed in the View project or (2) should a reference to the View project be placed in the Android/iOS/etc projects? Or is there a better solution than either of these two?
Edit:
(1) does not work because a reference to the App project from the View would create a circular dependency.
(2) should work (I think), but I'm having trouble getting the Application.Droid project to access the Application.View project namespace because when I add using Application.View;, the namespace isn't found in the Application namespace. Visual Studio attempts to fill in other Application namespaces (.Container, .Logic, .Droid, .Proxy) when I type in using Application.

The native project can have a reference to the View. It already does in a way, because it references the App library, which then references the View. Hence you aren't really adding any further dependencies by doing this, just allowing access further up the chain.
If you are having trouble the namespace, I suggest you start out with
global::Application.
That way it starts from the top, if its getting mixed up with project namespaces.

Related

.net library class not updated in web page

I just created a new web site in Visual Studio 2012. I also created a new Class Library. I added a class, another class inside that first class and then a method. I compiled the library and added as the reference in the bin folder for the web site.
In a aspx.cs page I can now see my new method. Great. I go to create a second method in the same location, go back in my aspx.cs page, can't see it. It says there is definition for this method.
I compile the class library just in case. Can't see it. I clean the solution, build the whole solution, still can't see it.
I actually have to remove the reference from the bin folder of the web site and add it back so that now I can see the second method.
I worked on another project where (I believe) things were set up the same way (web site + class library) and by typing the new method in the class and saving the file was enough to reach this method from an aspx page.
What can I change in my solution so that the new method in the class library can be seen directly?
ps: the aspx.cs page has using myLibrary; at the top;
Thanks
Make sure in your solution that you are using the References folder. Right-click it, choose "Add Reference" and then use the Solution tab to reference your class library project. Taking this approach, every time you update your class library the web project will automatically receive the update.
It sounds like you might be adding the binary to the BIN folder of the website project and then referencing it from there?
First of all check if build is going to debug folder or bin folder. If you are referencing project then make sure that build order is correct and dependency set accordingly. Also check for class library or project referred solution is not building on client profile, select targeted framework.

How do I use functionality available in an embedded jar file?

I'm trying to use GmailSender in my Xamarin Android app. My main project is referencing the binding library, and the binding library has 2 jars - GmailSender 1.1.jar, and mail.jar.
the GmailSender 1.1.jar file is set as an EmbeddedJar in properties, and mail.jar is set as an EmbeddedReferenceJar in properties.
The following image depicts how my project is set up (higher res image: http://i.imgur.com/Xbq5uKa.png)
This is where I got GmailSender 1.1.jar: http://gmailsender.blogspot.ie/
This is where I got mail.jar (renamed from mail-6.0.0.jar) http://www.java2s.com/Code/Jar/m/Downloadmail600jar.htm
How can I get my Xamarin Android app to use GmailSender?
There is a note regarding that issue on Xamarin docs:
Note: Due to bug 6695, when referencing the Java Binding project
directly from a Xamarin.Android project, none of the namespaces,
classes, or other members of the Java Binding project will be visible
in the IDE when working on the Xamarin.Android project. This bug will
be fixed in a future version of Xamarin.Android.
You won't be able to see the bindings unless you reference the generated dll (this is a workaround)
You need to reference the library using the namespace of your binding library. By default, it is probably using "BindingLibrary1" as the root namespace, so try adding a using directive for that namespace.

Errors when including Entity Data Model across referenced projects

Decided to take a dive into recreating a website so that it's an ASP.NET MVC web application. We were originally using the Entity Framework for it, figured to still use it since it works nicely enough. When doing some reading, noticed the there is no such thing as the App_Code/ folder for MVC applications, and that most people were creating a class library for their needs like that. So what I ended up doing was creating my MVC application and a class library, both in the same solution, and the MVC application was referencing the class library. The class library has my EDMX Entity Data Model file in it since some of my classes reference it and I thought that it would be easiest to have it in the library to reference. So here is a picture to what my solution layout is. But when I build and run the website, I get an error on a page that would reference the Entity Data Model. Here is a picture of what the error is.
So I thought, what if I placed the EDMX into my models folder since the error looks like it's complaining about not finding the entities. Here's a picture of my solution now with the move. But now, I'm getting a different error (picture). I'm kind of at a loss as to where to go from here. Is the way I have everything laid out and designed the proper and most efficient way to do it? If not could someone give me some advice?
Thanks, it's really appreciated!
Yes, you should be able to have the edmx in a class library and reference if from your main project. The first error is likely due to an incorrect connection string (check this blog post) but you may also have changed the build action of the edmx file somehow, make sure it is "Entity Deploy".
The second error is probably because you copied the edmx from your class library into the Models folder and it is still referencing the old namespace. To fix that, open the edmx in designer view and click on the background. One of the properties in the property window is Namespace, make sure that's set to the new place you want to keep it.
Edit:
Some things to try:
Clean and rebuild the project
Delete the Temporary ASP.NET Files folder referenced in the error message
Double check your cshtml files for old references to URG_MVC.Models namespace. For example, the line in the error should be IEnumerable<URGLibrary.Proposal>
Right click the edmx file and select Run Custom Tool to regenerate the model files

Why do I have "unknown type" in MVC project?

I have a C# MVC web application. I have added a code library to the project. I want to create a new class called TagBuilderCollection that inherits TagBuilder. It will give me a hierarchical structure to have a parent-child relationship for HTML tags I create with TagBuilder.
TagBuilder is apart of System.Web.Mvc. But despite the fact I've added System.Web.Mvc as a reference to the library project, and I've added the using statement to the top of the class file, I am still getting the intellisense error
Unknown type 'TagBuilder'
In my MVC project, I'm using TagBuilder in the Extensions folder with no reference issues. I just can't figure out why I can't reference it in my code library???
I had to add System.Web.WebPages as a reference to the library. Now it's working.
Despite the intellisense error, I attempted to build the project. VS kicked back an error saying that the error was (paraphrased) "forwarded to System.Web.WebPages. Try adding that as a reference." So I did. And now it works. I don't know why that mattered, but it did.

Linq-to-SQL datacontext not generating an object

I am working in a .NET 2.0, recently upgraded to .NET 3.5 environment (VS2008, VB.NET) on an existing ASP.NET website project. I am able to generate a Linq-to-SQL Class (also called a DataContext?) in the App Code folder, drag over tables from an active connection, and save it. Let's call it MyDB. When I go to the code-behind file for my page and try to declare an object of "MyDBDataContext" it is not in the intellisense, indicating that it is not accessible.
I checked the references, and that has to be set correctly because I made the .dbml file.
I made a new test windows app project and it behaved exactly as expected, and I could follow this blog without a problem.
Is there something inherent to web projects that doesn't allow for these auto-generated objects to be usable? Is App Code the right place to declare it?
If you can't tell from the above, I am new to the industry and really new to LINQ.
thanks for your help.
Try expanding the dbml file and open the designer.cs file underneath, and make sure the DataContext class is in the same namespace as the codebehind class. If not, either change the namespace or include it with a using Namespace statement the top.
If it your dbml is in a folder inside of '/App_Code/' it may pick up the folder's name as a namespace. Eg: '/App_Code/DAL' would have the namespace 'DAL'. Give it a namespace in the designer or just use the namespace it is given, if this is the case.

Resources