Create mailbox in Exchange 2003 using C# running on Windows Server 2008 - c#

I'm getting desperate so was hoping someone could help. We've re-written an old VB app that uses CDOEXM to create mailboxes in Exchange 2003. The new C# code is very similar and looks like this:
CDOEXM.IMailboxStore mailbox;
mailbox = (IMailboxStore)user.NativeObject;
mailbox.CreateMailbox(homeMDB);
user.CommitChanges();
The server running the code needed to have Exchange Management Tools installed for it to work (that installs the CDOEXM libraries that we require)
This works fine on XP, but we're also moving to Windows 2008 64bit servers, and I have been unable to install Exchange Management Tools on here because it says there's a compatibility issue.
Can anyone recommend a way around this? As I said, we're getting desperate because this is going to prevent a production release if we can't solve it, so would really appreciate some help.
Thanks
EDIT: incidentally I manually registered the CDOEXM dlls as a bit of a bodge, and I now get this error:
Problem creating mailboxSystem.ArgumentException: Value does not fall within the expected range.
at CDOEXM.IMailboxStore.CreateMailbox(String HomeMDBURL)
The homeMDBURL I am using is a valid one as far as I can tell though

I don't think CDOEXM is supported on Windows 2008. What about having a Windows 2003 Server around which hosts a WebService that does the mailbox creation stuff?
Another option is to create the mailbox without using CDOEXM. Note that this approach is totally unsupported by Microsoft. But if you populate enough properties (I don't know them all out of my head) like homeMDB and others, the Recipient Update Service (RUS) will create the mailbox on its next run. If I recall it correctly, the RUS runs every two minutes by default.
Btw, you did run your C# program as a 32bit process, right?

Related

Detecting and installing SQL Server Express with UWP app

I have written an UWP app for managing employees, timesheets etc.
How do I detect if SQL Server Express is installed and if not installed how do I setup SQL Server Express on the client computer? Is it possible to do it without running the exe file in 'fulltrust'?
I would also like to include the setup files in my app package with the configuration file to run a silent install on the client computer.
I have looked for a answer on many pages but could not find a real straight forward answer.
Some help here would be much appreciated.
when you have access to your client computer, you can run a check program in your setup process via checking if MS SQL Server Express registry key exists or not. If it exists, then it is installed.
Read this doc from Microsoft, there is a code snippet in the doc you can use:
https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2005/express-administrator/bb264562(v=sql.90)?redirectedfrom=MSDN
What do you mean by 'auto-detect' MS SQL Server Express installed'? Not sure what's your use case here.
Normally, you can not auto detect database to use since in many cases there could be multiple databases installed in the environment, and you don't know which one is the right one you are going to use. You have to know which database you are going to use first.
However, if you insist to detect database, you can do the port scan in your network which is really not a good idea.
So guess maybe your use case is unique.

EWS intermittent "Unable to connect to the remote server" - Works 99% of the time

I have a c# app that exports data from the database to the user's Exchange Calendar, using Microsoft.Exchange.WebServices (15.0.0.0). My app is DotNet 4.5.2 and I use Visual Studio 2013.
The app has been working fine for a year, and even now works 95% of the time. The app runs constantly on machine that I am logged into and monitor. This is a low volume process, perhaps 50 items get exported per day at most.
Every couple of days, the program will give this error:
"The request failed. Unable to connect to the remote server"
when the app is attempting to create an EWS connection to the server.
It will do this for maybe 10-20 items. So I shut it down, run it again, and it works perfectly fine on all the records that failed before.
This is my first EWS app, but I've been programming 30+ years and do have somewhat little knowledge of internet based apps.
Any helpful information or suggestions would be greatly appreciated!
Thank you kind people!
The internet often works, but should never be considered reliable. Anything using it should handle errors, and retry if desired. The classic approach is Exponential backoff. Its possible something nasty is going on, like your ISP swapped your IP address, or just intermittent failure. I don't know anything EWS specific, but there may also be sources of flaky issues there as well.

How to run a windows application as a web application

I did a windows application project with C#. Now, I wanna to run it as web application.(I mean, i want to install the application on server and the user from other places can connect to the server with a web link and test it).Since all the user do not have the visua studio software, I forced to do that. May you help me to figure this problem out?
Thanks in advance
You can't do that. You can have people be able to Remote Desktop to the server and then run the application. If you wanted it to be accessible via URL, you have to build a webpage.
Short answer: you can't run a Windows application directly in a web environment. And really there is NO WAY you should want that, either.
If you need remote access to the computer running the instance of your application, that can be done with the right software. I can think of TeamViewer, Radmin and Remote Desktop on top of my head.
If support for multiple concurrent users is required then you have two obvious choices:
Deploy your application on every clients, or
Make a Web application.
Now for option 1, there are different ways to do that. Depending of the complexity of your app you may require a Windows Installer setup package. For this there is multiple tools on the net. My personal favorite is WiX. Free, powerful and easy once you get the hang of it. Most installers will also ensure that requirements for the app to run are met, and install the missing components if necessary.
If all you have is a simple EXE file then you could be tempted to just package (ZIP) it and share it any way you want, but be warned: if the correct .NET Framework isn't installed on the client machine, it won't work. IMHO given the tools at your disposition to ensure a proper installation experience for the end user, you have no reason to do that. You can, however, consider using ClickOnce for this scenario.
If that doesn't help you, then please add more details on what your requirements are, maybe you'll get better advice.
PS: About "not every users having the Visual Studio software"... having VS installed should never, EVER be a requirement for the regular user.
You can't just run a Windows application as a Web Application. You need to re-write it as a web application. The users do not need Visual Studio to run your application as you have mentioned in your question. If you give some details of what your application does then maybe you will get some better help.
If you wrote your application using WPF it is possible to deploy it as an XBAP.
There are restrictions associated with deploying an application this way.
The minimum you would need to do is create a Web Application to host said XBAP.

Notification Services custom delivery channel DLL trust issue

We have an instance of SQL Notifcation Services for which we have written a custom delivery channel. We had this process up and running in our QA environment running Windows Server 2003 with SQL Server 2005. It took a little bit of tweaking to the get the custom DLL trusted however we got it all working.
We have since deployed this code to our Live environment. This runs Windows Server 2008 with an Instance of SQL 2005 for Notification Services but then we have an instance of SQL 2008 which hosts the actual DB instance for Notification Services. Notification Services works as it should however we cannot get the custom DLL to be trusted as a result the custom delivery channel won't work. We simply get the error
That assembly does not allow partially trusted callers
We have tried using the .NET configuration utility and caspol.exe to give the .dll full trust with no luck at all. The .dll is compiled as a .NET 2 dll as notification service requires this.
We are pretty much out of ideas at the moment and hoping someone can suggest something?
We have managed to fix our issue. It would appear that Windows Server 2008 is stricter in its implementation of code access. By giving granting access to the .DLL by it's strong name rather than it's path allowed Notification Services to access the code.
Notification Services was not at fault.
I think you have one of two choices:
Embrace SQL 2008 and get rid of Notification Services because it was deprecated. Use Reporting Services or SSIS to do what you need.
Revert back to SQL 2005.
IMHO, I'd go option 1. Continuing to build with deprecated tools is going to quickly find you in a situation where support (community or vendor) is going to be extremely hard to come by.
update
This was too long for comments.
Not to beat your head too much, but continuing to develop applications for a technology that was EOL'd (end of life) over 3 years ago was the first mistake. The EOL statement was made quite public.
The second was having a QA environment that is radically different from production. Before deploying anything to production, the QA environment should have been identical... same type of hardware, same OS's, same server versions and patch levels. Otherwise QA is a joke, as you've found.
Now, as to the "resolution", there really is only one path: Revert your production environment back to SQL 2005 with the appropriate patches in place.
I wish you luck.

Microsoft Access required for C# database access on end-user machines?

Silly question, perhaps.
I've developed an app on my machine that uses a Microsoft Access database (.mdb) to access certain information and populate a table with monitoring data using OLEDb.
The application works fine on my machine, but when I put the release on test machines (without MS Access), it crashes. Interestingly, if I were to launch the application on the testing machine with the database filename just renamed, it loads like it should albeit without the data.
I seem to get an UnauthorizedAccessException exception thrown which further clouds my confusion.
Both the development machine and the machine I'm testing it on have .NET 3.5 installed.
I would expect a barage of 'No's in reply to my question, but what the heck - does the testing machine need to have MS Access installed?
Regards
Try downloading the Office Connectivity Components here. This will let you read and create Access databases without having Access installed.
It doesn't need MS Access but you will need the required driver for your version of Access. You may need to do a test release that outputs to a log the exact Exception and message.
Make sure you have latest Jet 4 OLEDB drivers installed. There might also be a problem if you run the application from a network share (then it runs with restricted rights).
You say you got an UnauthorizedAccessException. I'd check read/write permissions to the .mdb file and location first.
If you're running as a service remember that they run under more restricted accounts.
You don't need Access itself. You will need to have JET drivers and associated files at least as current as the ones on your development machine — if you're recycling an old machine to use for testing that could be the problem.
However, this really sounds like a permissions issue, either on the database file itself or inside the file if you're using Access's security mechanisms.
It turns out the issue was a hardware problem. One of the serial ports on the card I was using had gone capput when it got moved to a new machine.
Turns out the problem wasn't database related, as the exception would've suggested.
Some interesting points on JET were raised though, which could be useful to anyone with Database access issues.
Thanks for your help guys.

Categories