This little thing took me about an hour of angry googling (that's my daily job lately) to fix. So, you want to use WCF Data Services to expose data in your MySQL database. You created a project, added ADO.NET Entity thingy, added WCF Data Service, and this last guy does not work throwing Failed to find or load the registered .Net Framework Data Provider at you.
The only thing you are missing is a reference to MySql.Data.Entity (if only it could add itself automatically like tens of others). Go and add it: References -> Add Reference -> Extensions -> Check MySql.Data.Entity. There are a lot of versions available. My installation required version 6.6.5.0. If you add wrong version, the your server will throw an error that would tell you which version it is looking for.
Nikolai Samteladze
Yeah... I couldn't come up with a better title.
Thursday, July 25, 2013
Enable Verbosely Errors in WCF Data Service
In case you want to see some additional info about the occurred exception (+ its stack trace). There are 3 ways to do this:
-
You can change your service configuration in InitializeService() method
public class MrSophisticatedServer: DataService<TestEntities> { public static void InitializeService(DataServiceConfiguration config) { // Make service to report errors in a nice way - doesn't really help.... config.UseVerboseErrors = true; .... } }
NOTE: There is one problem with this method. It does not work if your service (for some ridiculous reason) is not initialized. Basically, something goes wrong before InitializeService() is called. In this case use method 2 or 3 below. -
Add this attribute before your data service class
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
-
Add the following to your Web.config
Saturday, February 2, 2013
Download Terminates Because of Unknown Network Error
Recently happened with me: all my downloads (I tried Chrome and Mozilla) terminate after a while because of unknown network error. Pretty irritating, isn't it? After several hours I found the problem which was my anti-virus. I use ESET Smart Security and it does port checking by default. Disabling this option (Advanced Setup -> Web and Email -> Web access and antiphishing protection -> HTTP, HTTPS -> Uncheck Enable HTTP checking) permanently solved my problem with downloads.
I doubt that it is a good idea to disable it permanently. So, I turn it off every time I need to download something larger than 10 MB.
I doubt that it is a good idea to disable it permanently. So, I turn it off every time I need to download something larger than 10 MB.
Friday, January 25, 2013
Enable ASP in IIS 7.5
I don't really know why, but when you enable IIS in Windows 7 (as Windows Feature) it does not enable ASP automatically. So, of you have problems with ASP not presenting in IIS Manager, then go to IIS -> WWW Services -> Application Development Features and enable everything there. Here is a good guide with pictures on how to do it: http://www.codeproject.com/Articles/43132/How-to-Setup-IIS-6-0-on-Windows-7-to-Allow-Classic
Saturday, October 27, 2012
Show Dialog in Android After Device Boot Is Finished
What to do if you want to show an alert dialog right after the device boot is finished? You receive ACTION_BOOT_COMPLETED but you can't show an alert dialog from the broadcast receiver if you don't have any activities. Thus, what you need is to create one. But if you want your users to see only the dialog, your activity must be completely transparent.
1. Transparent activity style.
First, you need to create a transparent activity. Add this style to styles.xml:
2. Activity with a simple dialog.
Now lets create an activity that will show a simple dialog:
Obviously you need a broadcast receiver that handles ACTION_BOOT_COMPLETED broadcast (note that you need a permission to receive the broadcast):
In your manifest you must assign the created style for your activity and register the broadcast receiver. It should look something like this (note that you need a permission to receive the broadcast):
1. Transparent activity style.
First, you need to create a transparent activity. Add this style to styles.xml:
Any activity that has this style as a theme will be transparent.
2. Activity with a simple dialog.
Now lets create an activity that will show a simple dialog:
public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Message") .setTitle("Title") .setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { MainActivity.this.finish(); } }); AlertDialog alert = builder.create(); alert.show(); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }3. Broadcast receiver.
Obviously you need a broadcast receiver that handles ACTION_BOOT_COMPLETED broadcast (note that you need a permission to receive the broadcast):
public class OnBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent startIntent = new Intent(context, MainActivity.class); startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(startIntent); } }4. Android manifest
In your manifest you must assign the created style for your activity and register the broadcast receiver. It should look something like this (note that you need a permission to receive the broadcast):
That's pretty much all you need to show a dialog after the device's boot is complete. Source code can be obtained from Github.
Monday, October 22, 2012
Get the APK's Code Size in Android
In the early version of my DELTA Statistics application for Android I collected code size of an installed application. When a lot of statistics about an installed application is easy to get, code size slightly more complicated.
Step by step:
Step by step:
- Download IPackageStatsObserver.aidl and PackageStats.aild. You can get them from here.
- Create new package in your project and name it android.content.pm.
- Add IPackageStatsObserver.aidl and PackageStats.aild to the created package. You can do it by right-clicking on the package name and choosing Import option. Then select File System and click Next. Browse to the folder where you downloaded .aidl files, check the files you need and click Finish.
- Check that Eclipse automatically generated IPackageStatsObserver.java in gen.android.content.pm. Mine has some warning but trying to fix them is just a waist of time.
- Now we can get code size of application. In the example below I collect code size of all the installed applications. When I first wrote it I got a weird bug. Sometimes code size was 0 for the last N applications. N was different practically all the time, so, I though that it was a concurrency issue. As I understand, getPackageSizeInfo() method is invoked in another thread and because of that for loop can end before all the values of code size have been computed. To solve this problem I included a semaphore that is acquired at each loop iteration and is released after code size has been computed. It guarantees that getPackageSizeInfo() will finish before the next loop iteration will start.
context = getApplicationContext(); final PackageManager packageManager = context.getPackageManager(); List<ApplicationInfo> installedApplications = packageManager.getInstalledApplications(PackageManager.GET_META_DATA); // Semaphore to handle concurrency final Semaphore codeSizeSemaphore = new Semaphore(1, true); // Code size will be here long codeSize = 0; for (ApplicationInfo appInfo : installedApplications) { try { codeSizeSemaphore.acquire(); } catch (InterruptedException e) { e.printStackTrace(System.err); } // Collect some other statistics // Collect code size try { Method getPackageSizeInfo = packageManager.getClass().getMethod("getPackageSizeInfo", String.class, IPackageStatsObserver.class); getPackageSizeInfo.invoke(packageManager, appInfo.packageName, new IPackageStatsObserver.Stub() { // Examples in the Internet usually have this method as @Override. // I got an error with @Override. Perfectly works without it. public void onGetStatsCompleted(PackageStats pStats, boolean succeedded) throws RemoteException { codeSize = pStats.codeSize; codeSizeSemaphore.release(); } }); } catch (Exception e) { e.printStackTrace(System.err); } }
Tuesday, October 16, 2012
Skype Icon Missing (Windows Default Icon Instead)
Finally got my hands on this annoying problem with the Skype's icon. Instead of Skype logo icon I had an ugly default Windows icon in the taskbar (I have Skype pinned to the taskbar). When I unpinned Skype, the icon came back but no for a long time. Default Windows icon appeared after the next right click on the taskbar icon.
It happened to be not a Skype's problem but a problem with Windows icon cache. I rebuilt it, restarted the computer and the problem was solved. So, that's what you need to do to rebuild the icon cache:
It happened to be not a Skype's problem but a problem with Windows icon cache. I rebuilt it, restarted the computer and the problem was solved. So, that's what you need to do to rebuild the icon cache:
- Open Command Prompt (how? ehhh, type cmd in the search box in start menu).
- Type this commands (the last one will reboot the machine)
taskkill /IM explorer.exe /F cd /d %userprofile%\AppData\Local del IconCache.db /a shutdown /r /f /t 00
Subscribe to:
Posts (Atom)