C# ComVisible DLL not registering - events

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.

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!

MVC Entity Framework Conundrum: "missing using directive or an assembley reference?"

This project used to work. I fuddled with the connection string in Web.Config trying to get it to work with .accdb file. Forget that.
But now I can't get back home to a working project.
HomeController.cs code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using oesac.Models;
namespace oesac.Controllers
{
[HandleError]
public class HomeController : Controller
{
oesacEntities_connection _db;
public HomeController()
{
_db = new oesacEntities_connection();
}
=============================
E:\oesac_MVC\Controllers\HomeController.cs(52,42): error CS1061: 'oesac.Models.oesacEntities_connection' does not contain a definition for 'Courses' and no extension method 'Courses' accepting a first argument of type 'oesac.Models.oesacEntities_connection' could be found (are you missing a using directive or an assembly reference?)
(_db.Courses is underlined, just Courses has the underline)
//SEARCH BY COURSE TITLE
var courses = (from m in _db.Courses select m);
=======================
The Entity Container Name is:
"oesacEntities_connection"
It has 2 tables, Courses and Sponsors, and refreshes tables when I right click in .edmx window and select "Update Model From Database".
So database is there and VS 2010 sees it.
But for some reason there is a disconnect in referencing all this.
If I breeze through the popup after the errors that says "would you like to continue" I get a webpage with this error:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'oesac.MvcApplication'.
Source Error:
Line 1: <%# Application Codebehind="Global.asax.cs" Inherits="oesac.MvcApplication" Language="C#" %>
And this is what is in Global.asax.cs:
namespace oesac
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
I'm thinking if it was snake it would have bit me. But a little too new at this MVC dreamworld.
Ok, if someone else understands this better I can give them the green checkmark for correct answer. However, a friend at work said sometimes with EF you just have to wipe the slate clean and add a new Entity Framework class. And not get too clever. I had changed the names of the tables in VS 2010 .edmx file like it says you can and somehow the Gremlins took over.
Friend at work and 2 other people came to realize this after pulling out all their hair on one of there first major MVC projects.
And, yes, I did try all the mumbo jumbo of "Update Model From Database" right click in the .edmx in VS.

BasicHttpBinding Error - 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.

Windows bluetooth autopairing or disable authentication

I need windows to automatically pair with bluetooth devices. I don't want the user to have to click anything on the windows side. The server will be physically located somewhere the user cannot get to. Having to pair on the user side is fine. Windows just needs to accept any requests that come in without user input.
How can I accomplish this? Registry hacks? Replace a dll? A Hardware change (autopairing dongle or something)?
Is there any SDK that will give me the tools take care of this?
Currently I am using bluecove on the windows machine on top of Microsoft stack. I tried the Widcomm stack also with no luck.
The primary protocol that devices will use to connect is RFCOMM.
EDIT:
using the accepted answer below I came up with this code, that auto-pairs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InTheHand.Net.Bluetooth;
using System.Threading;
namespace BT
{
class BluetoothAutoSSP
{
public static void Main()
{
BluetoothAutoSSP c = new BluetoothAutoSSP();
EventHandler<BluetoothWin32AuthenticationEventArgs> handler = new EventHandler<BluetoothWin32AuthenticationEventArgs>(c.handleRequests);
BluetoothWin32Authentication authenticator = new BluetoothWin32Authentication(handler);
while (true)
{
Thread.Sleep(10);
}
}
public void handleRequests(Object thing, BluetoothWin32AuthenticationEventArgs args)
{
args.Confirm = true;
}
}
}
For the Microsoft Bluetooth stack: To support both traditional Bluetooth pairing as well as v2.1's Secure Simple Pairing use the BluetoothRegisterForAuthenticationEx function and in your callback function respond by calling BluetoothSendAuthenticationResponseEx.
See more at BluetoothWin32Authentication 32feet.NET docs which describes the way to handle that in the 32feet.NET Bluetooth library for .NET, my doc Bluetooth in Windows 7, and MSDN e.g. BluetoothRegisterForAuthenticationEx etc.
BTW Widcomm does not have a programatic way to respond to pairing (it does have a method to initiate pairing). BlueSoleil does have an API apparently.

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