Updates, please don’t do that…

Using a MySQL DOT-Net Conncetor and getting these error messages? Shared Memory Provider: No Process is on the other end of the pipe. Error 0. Unable to find the request .NET Framework Data Provider. It may not be installed. Or your login not working, but your password is right? Try this solution.

Using Visual Studio 2010, it’s possible to use MySQL databases. The trick is to use the MySQL DotNET Connector.

Everything was going swimmingly until for what appeared to be no reason, until one day I went to work on my project and I started getting a strange error message for what appeared to be no reason.

Shared Memory Provider: No Process is on the other end of the pipe.
Error 0.
Unable to find the request .NET Framework Data Provider. It may not be installed.

Exploring the exception shows that a connection to the database is made, but the login has failed for the username. However, the username and password work when logging in using the MySQL client. No drivers have changed, and MySQL works with all other applications just fine, just not the Microsoft development IDE. The connection string validated in a test environment, as did a raw connection with the MySqlConnection. EntityFrameworks, not so much.

Attempting to use EntityFrameworks from VS2010 results in an error dialog box that when dismissed goes back to the database wizard that brings up the dialog box again; the only way out is using Task Manager and violently killing the IDE’s process.

Attempting to use the .MySQL .NET/Connector installer to repair the installation doesn’t help, either. Yes, it updates the .dll files, yes it tweaks the registry, but no, it doesn’t help.

Making a new project and creating a new ADO.NET Data Model reveals something interesting: the MySQL providers are not listed anymore in VS2010.

The solution is to UNINSTALL the DotConnector and then re-INSTALL the same MySQL .NET/Connector.

The full installer indicates that it updates the VS2008 and VS2010 development environments. Trying the IDE again works perfectly. The ADO.NET Data Model shows the MySQL Data Provider, the Entity Frameworks doesn’t get stuck in an endless loop, and my code worked again without change.

What happened to cause all this? Turns out I had installed a minor VS2010 hotfix service pack at the end of the weekend. The result? The update silently uninstalled all non-Microsoft data providers.

Updates, please don’t do that…

Clearly, I’m not happy about that. Especially since it did it silently. If it told me that it was going to, or if it asked me to reinstall after the fact, I could live with it.

Uninstalling Intego Software

I’d rather eat an orange then brush my teeth with peppermint toothpaste than deal with cleaning up my system after using Intego’s software. If anything can bring the Windows reboot experience, coupled with the leaving of software cruft, to the Mac platform, this software does it in my opinion. Here’s how I finally got rid of it all. I hope.

I recently purchased a Mac bundle with software and it included software from Intego, consisting of the Personal Antispam and Personal Backup applications. I installed them, and from that point forward it was an experience I’ve regretted and have been trying to undo. Only now do I think I’ve made some progress toward that goal.

Frankly, I didn’t get what the backup software did for me over many of the free solutions out there, and while the personal antispam look intriguing, it was intrusive as well and I decided to fall back to Apple’s spam filter included in Mail.

Even if a product doesn’t make it into my main line of recommendations, I often will keep it around in the event I suddenly have use for it. This, for example, is how TypeIt4Me eventually won me over.

Intego went out of their way to annoy me straight from the start. How so? Every time I went to install a package from them, they felt the need to do what appeared to be a gratuitous reboot. It was like being on frickin’ Windows. And they had to install their own update manager, which had to take a glory spot in the menu bar. And it had to do updates, which required even more reboots. I was done with them at that point, but don’t even get me started on the subscription scheme that rode on top of the atrocity.

So I wrote to them asking them how to uninstall their software. Here’s the reply I got:

Proper removal of the software package requires using the Installer package located in your software bundle or disc. If you have manually attempted to remove the software, you will need to first, reinstall the software again, then use the same Installer package to properly remove the applications.

If you need to, you can re-download the installer for Internet Security Barrier X6 using the link below:

http://www.integodownload.com/en/isbx6.html

Open the installer and select to uninstall all software. Restart your computer.

Great, another reboot. Lucky for me, I hadn’t tried to go off on my own path, plus I had the original installation utility. I tried it, and it appeared to work.

Notice I said appeared?

One week later, LittleSnitch pops up and reports my system is spontaneously trying to access Intego’s update service for the very set of applications that, for all evidence I could tell, I removed and forgot about. Apparently, no so.

LittleSnitch also reveals it’s TaskManagerDaemon who’s trying to deal with Intego’s NetUpdate buried in /Library/Intego. Thank you LittleSnitch, curse you Intego.

Intego leaves cruft. Running cruft. Seems this isn’t new of them, according to Apple archives.

Part of the Mac culture is being a good citizen. In my opinion, I feel they aren’t.

After uninstalling the software in exactly the manner they prescribe, enter this this command at your terminal:
sudo find / -name Intego -print

I suspect you’ll develop a similar facial tick as it starts returning output after scanning your disk.

Go grab a root shell, you’re gonna wanna also wipe out:

  • /Library/Intego and everything below it.
  • /Library/Application Support/Intego and everything below it.
  • /Library/Preferences/Intego and everything below it.
  • /Users/wls/Library/Application Support/Intego and everything below it.

Oh, and you’ll want to Reboot as well.

…it’s not like I had other applications up or was doing anything important.

After the reboot, you’ll notice tons of console messages from launchd. Now you need to do this.
$ launchctl
launchd% remove com.intego.task.manager.notifier
launchd% remove com.intego.netupdate.agent
launchd% exit

And, you’ll need to remove some .plist files:
$ sudo rm -v /Library/LaunchAgents/*intego*
$ sudo rm -v /Library/LaunchDaemons/*intego*

And preferences, frameworks, keychains, and widgets:
$ sudo rm -vrf /Library/PreferencePanes/NetUpdate.prefPane
$ sudo rm -vrf /Library/Frameworks/IntegoiCalFramework.framework/
$ sudo rm -v /Library/Keychains/Intego.keychain
$ sudo rm -vrf /Library/Widgets/Intego\ Status.wdgt/

Reboot again.

UPDATE (12-Dec-2010): I’ve been in contact with Intego Support, [email protected], and they were kind enough to provide this extra information:

If there is anything left on your computer, you can remove it manually.

Can you please go into the following areas on the computer and delete any traces of Intego or VirusBarrier:

/Macintosh HD/Library/Intego
/Macintosh HD/Library/LaunchDaemons
/Macintosh HD/Library/LaunchAgents
/Macintosh HD/Applications
/Macintosh HD/Library/Preferences
/Macintosh HD/Library/Logs
/Macintosh HD/Library/Receipts
/Macintosh HD/Library/Startupitems
/Macintosh HD/Library/Widgets

Home Folder:

~/Library/Application Support
~/Library/Preferences

They were right, there’s logs, too.
$ sudo rm -rf /Library/Logs/NetUpdate/

Review: Walt gives Intego software installation TWO thumbs down. The reasons are obvious.

Defined in Multiple Assemblies

The predefined type ‘System.Func’ is defined in multiple assemblies in the global alias … mscorlib.dll and System.Core.dll. SOLVED!

Today I migrated a C#/WPF project in Visual Studio 2010 from .NET 3.5 SP1 to .NET 4.0. Immediately the compile failed issuing this set of errors:

  • The predefined type ‘System.Func’ is defined in multiple assemblies in the global alias; using definition from ‘c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll’
  • The predefined type ‘System.Func’ is defined in multiple assemblies in the global alias; using definition from ‘c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll’

To resolve this error involved understanding a little bit more about C#, .NET, and the Common Language Runtime (CLR).

According to C# 4.0 In A Nutshell from O’Reilly Press, on page 181 it says:

Some of the .NET types are used directly by the CLR and are essential for the managed hosting environment. These types reside in an assembly called mscorlib.dll and include C#’s built in types, ….

At a level above this are additional types that “flesh out” the CLR-functionality, …. These reside in System.dll, System.Xml.dll, and System.Core.dll, and together with mscorlib the provide a rich programming environment….

So mscorlib and System.Core are both needed. This begs the question, why is Func declared in both and thus causing a conflict? Or is it?

Further on in C# 4.0 In A Nutshell from O’Reilly Press, on page 183 in a general note it says:

A notable exception is the following types, which Framework 4.0 have moved from System.Core to mscorlib.dll:

  • The Action and Func delegates

This suggests a case exists where mscorlib is from our current .NET (the later one has Func), and System.Core is coming from the old one (which is where Func lives for that version).

How is this possible? It’s our projects fault.

This question on StackOverflow provides some insight; check out Simon‘s answer.

  1. Right-click the project and select Unload Project
  2. Right-click the project again and select Edit Project
  3. Scroll down in the XML to find the ItemGroup element; it’ll have Reference elements insider of it.
  4. Locate the Reference element that has Include=”System.Core” as an attribute.
  5. If it has other qualifiers, remove them. If it has a TargetFrameworkVersion subelement remove it.
  6. Save the XML.
  7. Right-click the project and reload it; try a build now.

In my case, I had an entry that looked like this:

<ItemGroup>
  <Reference Include=”System.Core”>
    <TargetFrameworkVersion>3.5</TargetFrameworkVersion>
  </Reference>
</ItemGroup>

Removing the TargetFrameworkVersion, shown in red above, un-pinned the dll from the older .NET framework and things worked just fine.

Find and Replace in Word using C# .NET

Solution to how to do a global search and replace in MS-Word, including across floating text objects, in C#/.NET.

Heads up, this article contains high quantity of geek content. Non-geeks should move along.

I’ve been trying to use Microsoft.Office.Interop.Word to perform a global bulk search and replace operations across an entire document. The problem was, however, if a document contained a floating text box, which manifested itself as a shape object of type textbox, the find and replace wouldn’t substitute the text for that region. Even using Word’s capability to record a macro and show the VBA code wasn’t helpful, as the source code in BASIC wasn’t performing the same operation as inside the Word environment.

What I wanted was a simple routine to replace text anywhere inside of a document. If you Google for this you’ll get the wrong kind of textbox, the wrong language, people telling you not to use floating textboxes, and all kinds of weird story iterators.

One site seemed to have the solution; many kind thanks to Doug Robbins, Greg Maxey, Peter Hewett, and Jonathan West for coming up with this solution and explaining it so well.

However, the solution was in Visual Basic for Applications, and I needed a C# solution for a .NET project. Here’s my port, which works with Office 2010 and Visual Studio 2010 C#/.NET 4.0. I’ve left a lot of redundant qualifiers and casting on to help people searching for this article.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.Office.Interop.Word;

// BEGIN: Somewhere in your code
Application app = null;
Document doc = null;
try
{
  app = new Microsoft.Office.Interop.Word.Application();

  doc = app.Documents.Open(filename, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing);

  FindReplaceAnywhere(app, find_text, replace_text);

  doc.SaveAs(outfilename, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing);
}
finally
{
  try
  {
      if (doc != null) ((Microsoft.Office.Interop.Word._Document) doc).Close(true, Missing, Missing);
  }
  finally { }
  if (app != null) ((Microsoft.Office.Interop.Word._Application) app).Quit(true, Missing, Missing);
}
// END: Somewhere in your code             



// Helper
private static void searchAndReplaceInStory(Microsoft.Office.Interop.Word.Range rngStory, string strSearch, string strReplace)
{
    rngStory.Find.ClearFormatting();
    rngStory.Find.Replacement.ClearFormatting();
    rngStory.Find.Text = strSearch;
    rngStory.Find.Replacement.Text = strReplace;
    rngStory.Find.Wrap = WdFindWrap.wdFindContinue;

    object arg1 = Missing; // Find Pattern
    object arg2 = Missing; //MatchCase
    object arg3 = Missing; //MatchWholeWord
    object arg4 = Missing; //MatchWildcards
    object arg5 = Missing; //MatchSoundsLike
    object arg6 = Missing; //MatchAllWordForms
    object arg7 = Missing; //Forward
    object arg8 = Missing; //Wrap
    object arg9 = Missing; //Format
    object arg10 = Missing; //ReplaceWith
    object arg11 = WdReplace.wdReplaceAll; //Replace
    object arg12 = Missing; //MatchKashida
    object arg13 = Missing; //MatchDiacritics
    object arg14 = Missing; //MatchAlefHamza
    object arg15 = Missing; //MatchControl

    rngStory.Find.Execute(ref arg1, ref arg2, ref arg3, ref arg4, ref arg5, ref arg6, ref arg7, ref arg8, ref arg9, ref arg10, ref arg11, ref arg12, ref arg13, ref arg14, ref arg15);
}

// Main routine to find text and replace it,
//   var app = new Microsoft.Office.Interop.Word.Application();
public static void FindReplaceAnywhere(Microsoft.Office.Interop.Word.Application app, string findText, string replaceText)
{
    // http://forums.asp.net/p/1501791/3739871.aspx
    var doc = app.ActiveDocument;

    // Fix the skipped blank Header/Footer problem
    //    http://msdn.microsoft.com/en-us/library/aa211923(office.11).aspx
    Microsoft.Office.Interop.Word.WdStoryType lngJunk = doc.Sections[1].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.StoryType;

    // Iterate through all story types in the current document
    foreach (Microsoft.Office.Interop.Word.Range rngStory in doc.StoryRanges)
    {

        // Iterate through all linked stories
        var internalRangeStory = rngStory;

        do
        {
            searchAndReplaceInStory(internalRangeStory, findText, replaceText);

            try
            {
                //   6 , 7 , 8 , 9 , 10 , 11 -- http://msdn.microsoft.com/en-us/library/aa211923(office.11).aspx
                switch (internalRangeStory.StoryType)
                {
                    case Microsoft.Office.Interop.Word.WdStoryType.wdEvenPagesHeaderStory: // 6
                    case Microsoft.Office.Interop.Word.WdStoryType.wdPrimaryHeaderStory:   // 7
                    case Microsoft.Office.Interop.Word.WdStoryType.wdEvenPagesFooterStory: // 8
                    case Microsoft.Office.Interop.Word.WdStoryType.wdPrimaryFooterStory:   // 9
                    case Microsoft.Office.Interop.Word.WdStoryType.wdFirstPageHeaderStory: // 10
                    case Microsoft.Office.Interop.Word.WdStoryType.wdFirstPageFooterStory: // 11

                        if (internalRangeStory.ShapeRange.Count &gt; 0)
                        {
                            foreach (Microsoft.Office.Interop.Word.Shape oShp in internalRangeStory.ShapeRange)
                            {
                                if (oShp.TextFrame.HasText != 0)
                                {
                                    searchAndReplaceInStory(oShp.TextFrame.TextRange, findText, replaceText);
                                }
                            }
                        }
                        break;

                    default:
                        break;
                }
            }
            catch
            {
                // On Error Resume Next
            }

            // ON ERROR GOTO 0 -- http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

            // Get next linked story (if any)
            internalRangeStory = internalRangeStory.NextStoryRange;
        } while (internalRangeStory != null); // http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
    }

}

Let me know if it worked for you; bug fixes and enhancements welcome.

“Mail: SafetyNet not needed” log messages

New messages about SafetyNet not needed are appearing in my logs from OS X’s Mail. Trying to figure out what they are. Looking for ideas as Google was dry.

Warning this is a geek-related post, if you’re looking for photography and humor, try another entry or browse the comics.

I’ve noticed OS X’s Mail going something a little weird. I’ve got GeekTool pumping messages to my desktop in the background, and I keep seeing this filling the log:

Mail: SafetyNet not needed – wrongState:0
Mail: SafetyNet issues SELECT before CLOSE – wrongState:0

I’m trying to figure out what it means.

I’ve also noticed before that happens, I see this from /Applications/Mail.app/Contents/MacOS/Mail:

ATS AutoActivation: Query timed out. (elapsed 5.0 seconds. params: queryString = {com_apple_ats_name_postscript == “Helv” && kMDItemContentTypeTree != com.adobe.postscript-lwfn-font}, valueListAttrs = {{type = immutable, count = 1, values = (
0 : {contents = “kMDItemContentType”}
)}}, sortingAttrs = {{type = immutable, count = 1, values = (
0 : {contents = “kMDItemContentModificationDate”}
)}}, scopeList = {{type = immutable, count = 1, values = (
0 : {contents = “kMDQueryScopeComputer”}
)}}.)

The only other interesting behavior is that sometimes when I close the laptop lid and it goes into calmshell sleep, when I open the lid, I soon find that Mail is locked up to the point that it needs a Force Quit to exit, as Quit is unresponsive. Activity Monitor as well as Mail’s own activity status shows nothing going.

Anyone else seeing this behavior or know what it means?