Mono Android cross platform applications - c#

I'am new to Mono and currently working on Mono for Android. I want to re-use the core or services layer so I created a separate project for services layer so I can use it later for iPhone and Windows mobile apps. In the services project there are some references to the web services which are call for various transactions.
When I try to call the the web service by referencing the services project from a Mono Android application I revived "System.TypeLoadException: Could not load type xxxx" exception.
The web services and the service project are working fine when tried it with a simple windows app.
Is there any way to achieve this.
I tried to link classes as mentioned in following article .
http://docs.xamarin.com/Android/Guides/Application_Fundamentals/Building_Cross_Platform_Applications/Sharing_Code_Options
Bit I found that web service referenced and resource file references, etc are not referring when you link a class. Example if I link a class in project B from Project A, if the class has web service calls and referenced resource files, once you linked to project A you'll get build errors. Saying the web services and resource files are can not be found. I linked the resource files as well. But still I revived the same errors.
Any help on these issues are greatly appropriated. Thanks.

If you are any good at French... then the sample at http://www.e-naxos.com/Blog/post/Strategie-de-developpement-Cross-Platform-Partie-2.aspx (and http://www.e-naxos.com/Blog/post/Strategie-de-developpement-Cross-Platform-Partie-3.aspx) has some good information on sharing web service references between windows, windowsphone and monodroid
The key thing the author does is to import the web references separately for the two different paltforms - and to then use one #if to separate the different code.
I did start translating it... https://docs.google.com/document/d/1UQsy80qmXkVO7BRUb3f3vUxO2uQz9af1_PIQykAGzJA/edit - but pigeon English at best I'm afraid!

Related

How do I distribute a Windows service that depends on a class library?

I have a Visual Studio solution. This solutions contains two projects. The first is a class library with all methods that communicate with sql server db. The second is a windows service project will run every 30 minutes.
How do I distribute this setup in one package?
I have tried:
1-adding the class library as a reference to windows service.
2-create a setup project and adding the windows service in the application folder.
3-adding the windows service and the class library to the application folder.
this is a screenshot for the error.
I think this error because the class library couldn't reach the SQL db.
You are looking to deploy a windows service that is dependent on a DLL.
"deploy" is the standard for what you're calling "distribute". You understand the underlying concept but just realize that the standard is called "deploy".
There are details to do this here...
Windows Service Deployment

How to call a C# class library from a Classic ASP web site on Azure Web Services?

I have a Visual Studio 2015 solution with 2 projects:
A classic ASP web site.
A C# class library.
How do I call the C# methods from within the classic ASP pages?
I will deploy the solution to Azure App Services.
I do know that I could create a web API and call it that way. But I am wondering if there is any other way to do this.
UPDATE:
I made the C# class "COM-Visible" and checked the “Register for COM interop” option, and everything works correctly on my development machine.
But when I publish the solution to Azure Web Services, it doesn't work. The Classic ASP page runs fine, but I get this error when trying to create the object:
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/index.asp, line 34
800401f3
It seems “Register for COM interop” doesn’t work in Azure App Services. I know I could create a VM and register the dll manually, but I would prefer to use Azure App Services instead.
I think the two methods you mentioned - Web API (or similar intermediary service) and Server.CreateObject (needs a COM-visible .NET assembly) are your only two options in Classic ASP.
If the .NET assembly/library you want to use is not COM-visible, and you don't have access to source code, you can create a wrapper - your own .NET assembly that is COM-visible, with pass-through methods - you call your assembly from Classic ASP, and your assembly passes required parameters to the library you actually want to use, and returns results of the corresponding methods.

UWP VS2015 .Net 4.61 Add Web Reference Button Missing

Any help would be greatly appreciated!! I have scoured the web trying to find an answer. I am writing a UWP app that will be deployed to the Xbox platform. I need to access a web service written in .Net 2.0. In earlier versions of .Net / Visual Studio the Add Web Reference Button was hidden in a panel accessed through ->Add Service Reference ->Advanced ->Add Web Reference. With latest build of VS2015 the Add Web Reference Button is missing. Did this completely go away or is it hidden even deeper in the environment somewhere?
XML Web Services, also known as ASMX services, were the predecessor of Windows Communication Foundation (WCF). You can access Web Services by adding a service reference just as you would for any other WCF service.
A service reference enables a project to access one or more Windows Communication Foundation (WCF) services. Use the Add Service Reference dialog box to search for WCF services in the current solution, locally, on a local area network, or on the Internet.
For more info, please How to: Add, Update, or Remove a Service Reference.

Share a class between Windows Universal app and Azure Mobile Service

I'm developing Windows Store Universal app that uses Azure to store data.
In Visual Studio, there is four projects (Windows, Windows Phone, Shared, Mobile Service).
In Shared projects there is a class ToDoItem.cs. I want it to be used by all projects to avoid code repetition.
The problem I have is that I cannot add a reference to ToDoNotes.Shared in MobileService project. If I do it the other way round, that is, if I have this class in MobileService and reference it in Windows and Windows Phone projects I hit the same problem.
Is it possible to share this class across all projects?
An Azure project can only reference a classic class library... Universal Apps can only reference portable class libraries so you can not reference the code in this manner... There is one trick left in the arsenal, that is to add the file to both the shared project and the azure project as a link. This will link the file to the azure project Instead of copying the file into the azure project folder directory. See Photo below
The hard part will be trying to use the same code because certain objects have been moved from one namespace to another between universal apps and standard.net such as the XmlDocument, httpclient etc. Your code may have quite a few ifdef statements and this might end up being more trouble than it is worth.
Assuming ToDoItem.cs is like a object model, it should be put in a strongly named class library that can be referenced to from any project

Is it possible to run F# WebApi (OWIN) project in Azure Web Roles?

I'm not sure if this is F# specific or something else, but what could cause the following error message when trying to debug locally an Azure cloud service:
The Web Role in question doesn't seem to be a web application type project.
I added an empty F# web api Project to a solution (which adds Global.asax etc., I added an OWIN startup class Startup etc.) and then from an existing cloud service project I picked Roles and chose Add -> Web Role Project in solution, which finds the F# web project (its project type guids are 349C5851-65DF-11DA-9384-00065B846F21 and F2A71F9B-5D33-465A-A702-920D77279786), of which the first one seem to be exactly the GUID that defines a web application type.
However, when I try to start the cloud project locally, I get the aforementioned error message. I have a C# Web Role project that will start when I remove the F# project. I also have F# worker role projects that start with the C# web role project if I remove this F# web role project. If I set the F# web project as a startup project, it starts and runs as one would expect, normally.
Now, it makes me wonder if this is something with F# or could this error message appears inC# too, but I didn't find anything on Google. Can anyone shed light into this?
<edit: Additionally, in the F# trying to open Package/Publish Web tab in project settings will give the following error message
An error occurred trying to load the page. Specified cast is not valid.
I suspect this doesn't matter and may be just a bug in how VS handles the project or in F# MVC 5 template.
<edit for a solution of sort:
It looks like a solution to create e Web Role as a C# project and then include the web projects as ordinary F# projects works. A caveat here is that during this time the F# Web API template was updated. As of now, I used Web API 2.2 and Katana 3.0 from the 1.13 version of F# MVC template. As a bonus amongst many things, it looks this model has the added benefit of reduced deployment package size as blogged by Olaf Loogman at Reducing the size of an Azure Web Role deployment package.
Rather straightforward instructions for publishing multiple sites for one role can be had from Tips for Publishing Multiple Sites in a Web Role.
The specified cast not valid error happens with older versions of F# tooling. 3.1.2 should fix that issue.
I personally have created standard worker roles projects without a problem, and f# websites hosted in azure, but not f# web roles - I suspect that the support for them isn't great. Out of curiosity, why are you using a web role rather than a website project?

Categories

Resources