BasicHttpBinding Error - Xamarin - xamarin

Problem is not calling the wcf function using basichttpBinding and showing an error.
No host to route error comes up on Visual Studio.
Unhandled Exception:
System.Net.WebException: Error: ConnectFailure (No route to host)
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using HelloWorld_App4.localhost;
namespace HelloWorld_App4
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
localhost.Service1 obj = new localhost.Service1();
obj.GetData(32, true);
UIApplication.Main(args, null, "AppDelegate");
}
}
}

What license have you got?
If you only have the Indie license you wont be allowed to access web/wcf services and have to rely on rest services.
I found that out the hard way but then just switched ot using ASP.Net Web API to create my services. Simple and much cheaper that to buy the business license.

Related

Team recording bot from scratch(error at response)

We are creating a recording bot in .netframework 4.7.2 using the bot framework. We are making this bot from scratch. we were stuck at one point. please see the image below to see the error we are facing: What we are trying to do is we are making a bot controller and in that, we are getting an error at ( await Adapter.ProcessAsync(Request, Response, Bot)) response. please see the code below:
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Integration.AspNet.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using HttpGetAttribute = System.Web.Http.HttpGetAttribute;
using HttpPostAttribute = System.Web.Http.HttpPostAttribute;
namespace ScratchTeamrecordingBot.Controllers
{
[System.Web.Http.Route("api/messages")]
public class HomeController : ApiController
{
private readonly IBotFrameworkHttpAdapter Adapter;
private readonly IBot Bot;
public HomeController(IBotFrameworkHttpAdapter adapter, IBot bot)
{
Adapter = adapter;
Bot = bot;
}
[HttpPost, HttpGet]
public async Task PostAsync()
{
// Delegate the processing of the HTTP POST to the adapter.
// The adapter will invoke the bot.
await Adapter.ProcessAsync`(Request, Response, Bot);
}
}
}
We are creating a recording bot in .netframework 4.7.2 using the bot framework. We are making this bot from scratch. we were stuck at one point. please see the image below to see the error we are facing: What we are trying to do is we are making a bot controller and in that, we are getting an error at ( await Adapter.ProcessAsync(Request, Response, Bot)) response. please see the code below:
Go to View > Error List in Visual Studio and check the error message. But probably, your error is because you are using .Net Framework. If you check the type of the Response object you will see is type of Microsoft.AspNetCore.HttpResponse.IBotFrameworkHttpAdapter . My recomendation is to use .Net Core for your project.
For information about the IBotFrameworkHttpAdapter go here
Hope you find this information useful :)
Best regard!

How can I create a WCF Service Application in Visual Studio that does NOT use a Web Server

I have a simple task: A program (executable) is supposed to call a function of another program (also executable) with some parameters. Program A is supposed to be started, call the function and then terminate. Program B is legacy program that has a GUI and runs continuously. Both programs run on the same Windows PC and use the .NET Framework. I have no experience in web development and Program B is not supposed to run as a web service! Named pipes seem like a good option.
I researched what the best method would be and wanted to try WCF. The documentation claims that "A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application". From that I understand that I can run Program B as a service without hosting a web server.
However everything I see in Visual Studio seems to presume I want to run a server. Wenn I want to create a new WCF project in Visual Studio the only options are a library or "A project for creating WCF service application that is hosted in IIS/WAS". Once I've created said project the debugger wants me to choose a browser for hosting the service.
In another StackOverflow topic a popular suggestion was using this website as a guide and simply removing the http references since the guide is for both named pipes and http. Another indication that it should be possible.
So can someone point me in the right direction? What am I missing? How can I use WCF with nothing related to Web Development involved?
You have already been on the way, it is enough to host the web service in Program B, without specifying a web server. this is called a self-hosted WCF. As the link you provided mentioned, the Service host class is used to host the WCF service, which means that we can host the service in the Console/Winform, and so on.
Here is an example of hosting the service in a Winform application.
public partial class Form1 : Form
{
ServiceHost serviceHost = null;
public Form1()
{
InitializeComponent();
Uri uri = new Uri("http://localhost:9009");
BasicHttpBinding binding = new BasicHttpBinding();
serviceHost = new ServiceHost(typeof(MyService), uri);
serviceHost.AddServiceEndpoint(typeof(IService), binding, "");
ServiceMetadataBehavior smb = new ServiceMetadataBehavior()
{
HttpGetEnabled = true
};
serviceHost.Description.Behaviors.Add(smb);
System.ServiceModel.Channels.Binding mexbinding = MetadataExchangeBindings.CreateMexHttpBinding();
serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), mexbinding, "mex");
serviceHost.Open();
}
private void Form1_Load(object sender, EventArgs e)
{
if (serviceHost.State==CommunicationState.Opened)
{
this.label1.Text = "Service is running";
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (serviceHost.State==CommunicationState.Opened&&serviceHost.State!=CommunicationState.Closed)
{
serviceHost.Close();
}
}
}
[ServiceContract]
public interface IService
{
[OperationContract]
string Test();
}
public class MyService:IService
{
public string Test()
{
return DateTime.Now.ToLongTimeString();
}
}
After that, we could consume it by using a client proxy.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/accessing-services-using-a-wcf-client
Feel free to let me know if there is anything I can help with.

How to programmatically set COM+ Component -> Transactions to Not Supported?

I am looking for a solution to programmatically modify Com+ Component Property -> Transaction Support to “Not Supported”
The manual steps are the following:
Open Component Services dialog (comexp.msc)
Expand Component Services -> Computers -> My Computer
Find and expand COM+ QC Dead Letter Queue Listener
Expand folder Components inside the opened component
Find component QC.DLQListener and open context menu for this component and select properties
On the Properties screen, select “Transactions” tab and set Transactions Support to Not Supported
Click “OK” to Save the changes
After I spent several hours on this problem, I've finally got a solution on C#.
I've got a huge insight from the following articles:
Changin the transaction atribute using COMAdminCatalog
Retrieve settings from COM+ components via C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COMAdmin;
namespace SetComPlusTransactionsToNotRequired
{
class Program
{
static void Main(string[] args)
{
COMAdminCatalog catalog;
COMAdminCatalogCollection applications;
// Get the catalog
catalog = new COMAdminCatalog();
// Get the list of all COM+ applications contained within this catalog
applications = (COMAdminCatalogCollection)catalog.GetCollection("Applications");
applications.Populate();
foreach (COMAdminCatalogObject application in applications)
{
if (application.get_Value("Name") == "COM+ QC Dead Letter Queue Listener")
{
COMAdminCatalogCollection components;
components = (COMAdminCatalogCollection)applications.GetCollection("Components", application.Key);
components.Populate();
foreach (COMAdminCatalogObject component in components)
{
Console.WriteLine("Component: " + component.Name);
component.set_Value("Transaction", COMAdminTransactionOptions.COMAdminTransactionNone);
}
components.SaveChanges();
}
}
}
}
}

C# ComVisible DLL not registering

I'm working for someone running a windows 2003 server. They want me to make a SMTP sink which can categorize what database and table we want to send messages to. They don't have exchange on this server, only the default virtual SMTP server.
I've made a class, which I think should fire when the SMTP servers onarrival event occurs. I'm having an issue registering my class however, when I run RegAsm /regfile i'm getting a "Warning, RA0000: no registeration will occur, no types to register." if I run RegAsm with /TLB it will tell me types were registered, but by class doesn't show up in the global registery and my class isn't called when mail is sent to the server. I'm a little at a loss as to what I'm doing wrong.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace SMTPSink
{
[Guid("????-????-?????-????")]
[ComVisible(true)]
[ProgId("SMTPSINK")]
public class SMTPSink : CDO.ISMTPOnArrival
{
SMTPSink()
{ }
void CDO.ISMTPOnArrival.OnArrival(CDO.Message Message, ref CDO.CdoEventStatus EStatus)
{
//Simple test to see if this fires on mail arrival
}
}
}
You forgot to make the constructor public. Required to export a coclass that doesn't have the [noncreatable] type library attribute. Fix:
public SMTPSink()
{ }
Or just omit it if it doesn't do anything useful.

PROBLEM :An error message cannot be displayed because an optional resource assembly containing it cannot be found

I created Windows Mobile Application and I loaded web service that contain one method (GetNumber). When I call this method from my emulator I got a following exception
An error message cannot be displayed because an optional resource assembly containing it cannot be found.
Can anyone help me. This is my code from WM Application, it is very siple.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MobileClientApp;
namespace MobileClientApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MobileClientApp.localhost.WebService m = new MobileClientApp.localhost.WebService();
int result;
bool resbool;
m.GetNumber(10, true, out result, out resbool);
label1.Text = result.ToString();
}
}
}
For a very good explanation:
http://blogs.msdn.com/b/netcfteam/archive/2004/08/06/210232.aspx
(excerpt from above)
There has been some confusion about the error message: "Could not find resource assembly". Basically, this means that there is some exception that has happened in the program. The error did not happen because it could not find the resource assembly. The resource assembly that it is searching for contains exception messages (strings) that would be helpful in debugging what went wrong with the program.
Since the user is never expected to see this error message if the program works as expected and all exceptions are handled appropriately, it was decided (due to size constraints) that the resource assembly that has these error strings are never put on a user's device. Thus the main target audience of these error strings are developers who would like to debug issues. Hence, when you do an F5 deploy onto the device, the System.SR.dll assembly which have these error strings are copied to the device and the developer can see the error messages. But in case .Net Compact Framework is installed from a redistributable or you are using .Net Compact Framework that come with the device (as a user of the device would be doing), the System.SR.dll is not present on the device. Hence, if the application did come upon an exceptional condition that wasn't handled by the application, this "Could not find resource assembly" message would be shown to the user.
If you are not using Visual Studio F5 deploy to the device and would still like to see the exception messages, you can achieve this by taking the System_SR_[Language].CAB where [Language] corresponds to the language in which you want to see the error message to appear and clicking on the cab file to install it
Sounds like you are missing an assembly in your deployment.

Resources