Alexander Anikin's blog

My personal blog

TFS Addin for Monodevelop – error adding repository

leave a comment »

Found strange issue when trying to add new repository using TFS Addin in Monodevelop (ver 4.0.3.4) on my Mac.

After I setup repository and click button to add – get this error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Xml.XmlException: Document element did not appear. Line 1, position 1. at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0 at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0 at System.Xml.XmlReader.MoveToContent () [0x00000] in <filename unknown>:0 at MonoDevelop.Core.Serialization.XmlConfigurationReader.Read (System.Xml.XmlReader reader) [0x0000d] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/43da787a/source/monodevelop/main/src/core/ MonoDevelop.Core/MonoDevelop.Core.Serialization/XmlDataSerializer.cs:238 at MonoDevelop.Core.Serialization.XmlDataSerializer.Deserialize (System.Xml.XmlReader reader, System.Type type) [0x00000] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/43da787a/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Serialization/XmlDataSerializer.cs:102 at MonoDevelop.VersionControl.VersionControlService.GetConfiguration () [0x00034] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/43da787a/source/monodevelop/main/src/addins/VersionControl/ MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs:597 at MonoDevelop.VersionControl.VersionControlService.AddRepository (MonoDevelop.VersionControl.Repository repo) [0x00000] in /Users/builder/data/lanes/monodevelop-mac-monodevelop-3.0.3-branch/43da787a/source/monodevelop/main/src/addins/VersionControl/ MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs:577 at TeamAddins.VersionControl.TFS.GUI.RepositoryMenu.AddRepositoryHandler (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 — End of inner exception stack trace — at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0 at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0 at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <filename unknown>:0 at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0 at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0 at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000] in <filename unknown>:0

 

Solution is easy – you should open the directory: /Users/<Your Login>/Library/Preferences/MonoDevelop-3.0 and look into the file ‘VersionControl.config’. In my case it was empty. This means – corrupted. Just delete it and Monodevelop will recreate it. This will be fixed as bug in future releases.

Advertisements

Written by Alex Anikin

July 26, 2012 at 10:31 pm

Posted in Mac, Monodevelop

Predictable memory disposing in Monotouch

leave a comment »

I have tasks:

– do huge memory block allocation in iOS (using Monotouch) application (like list with ~20Mb strings);

– clear list and have predictable memory disposing (using Garbage Collector, it should do this in time, or when we need more mem or etc).

This tasks was born from another big task. I should open huge txt files using QLPreviewController. But all I can see – memory was allocating and never disposing (but this story not about it, this leak Xamarin planning to fix it in 5.3.5 or 5.3.6 release – will wait ).

To check this allocations I used XCode -> Instruments -> Activity Monitor (btw very useful tool – highly recommended!)

My tests :

1. Alloc 20Mb -> check it in Activity Monitor (+20Mb)-> Dispose variable -> Wait and do something with app (alloc more, add, delete items) -> Check -> nothing changes – 20Mb still.

2. Alloc 10*20 Mb items-> Check – my app has almost the memory (if i will try to get more ~10-20Mb  – iOS will close my app) -> Dispose 5 items (~100Mb) -> Waiting (thinking about GC) + do something (thinking about GC again) -> Check  – nothing – ~200Mb

3. The same with 2, but start use GC.Collect (GC.MaxGeneration, GCCollectionMode.Forced); after disposing – Waiting (thinking about GC) + do something (thinking about GC again) -> Check  – nothing – ~200Mb

4. …

n. Wow! -> The same with 3, but after allocation I add GC. AddMemoryPressure (size); and after disposing GC. RemoveMemoryPressure (size); -> Activity monitor shows me that I have memory cleared and available for future allocations.

I can be wrong somewhere and please let me know my mistakes.

Written by Alex Anikin

July 10, 2012 at 9:46 pm

Posted in C#, iOS, Monotouch

Hacking .Net

leave a comment »

Great video about hacking .Net applications: http://vimeo.com/43536532

More details here: http://www.digitalbodyguard.com

Written by Alex Anikin

July 10, 2012 at 9:06 pm

Posted in .Net

PowerPoint Web Application encountered an error: Service unavailable. Please try again later.

leave a comment »

That’s funny, but PowerPoint stop working today without any visible reasons. Error message about service anavailable

I tryed to get into PowerPoint Service Application, but System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

and this in log:

1: “Could not find default ServiceProxy or it does not implement IWacServiceApplicationProxy”

2: “Unhandled exception caught when executing web method handler: System.NullReferenceException”

First of all – re-create PowerPoint Service Application. Problem with given key is gone.

Investigation… Something wrong with the PowerPoint application proxy. This solution using UI did’t work for me and  . It was not hooked up to the default proxy group, but admin pages said different. (Thanks to Dale Hirt)

Get-SPPowerPointServiceApplicationProxy | Remove-SPPowerPointServiceApplicationProxy -confirm

Add new one w-AddToDefaultGroup switch:

Get-SPPowerPointServiceApplication | New-SPPowerPointServiceApplicationProxy -Name “PowerPoint Proxy” -AddToDefaultGroup

Verification:

$(Get-SPPowerPointServiceApplication).ServiceApplicationProxyGroup.DefaultProxies

Written by Alex Anikin

May 12, 2012 at 10:11 pm

Making a Request to WebService in Visual Studio from Specific IP address

leave a comment »

Hey all  –

Task:

1. I have a web-service refference in my project. I update it time to time. It’s OK.

2. I have several network adapters in my system.

The main thing – I need to call a WebMethod refferenced in my project from specific IP.

Solution:

As you can see – VS generating class for Web Service Refference and it’s partial. So you can override  some very useful methods. In my case I should override GetWebRequest and change it’s properties. For changing EndPoint I should use ServicePoint.BindIPEndPointDelegate.

Example:


public IPEndPoint BindIpEndPointCallbackForIP(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount)
{
return new IPEndPoint(_currentLocalIp, 0);
}

protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request = (HttpWebRequest) base.GetWebRequest(uri);
request.Timeout = 10000;
if (_currentLocalIp != null)
{
request.ServicePoint.BindIPEndPointDelegate = new BindIPEndPoint(BindIpEndPointCallbackForIP);
}
return request;
}

I’m trying to make end-point (string in bold) with specific port (ex. 443 or 80), but it fails (why?). And in my case it doesn’t work with IPv6.

Written by Alex Anikin

February 13, 2012 at 2:50 pm

Posted in .Net, C#

Error Accessing SharePoint Document Library from Microsoft Office Open or Save As Dialog

leave a comment »

We got this issue from Windows Server 2008 from Citrix users. They tried to open or save document directly to SharePoint, but a dialog couldn’t browse into needed folder. And this works fine from Windows Server 2003.

Our server was in Trusted Sites with automatic login. The main problem was in WebDav client – it don’t get and use any browser sertting (so do nothing with Trusted Sites and so…)

Resolution for Windows Server 2008:

1. Need to install Desktop Experience with WebDav client and reboot server. (There was issues with Citrix after installation – need more investigation about.)

2. At AppServer need to add multiple-string key AuthForwardServerList to [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WebClient\Parameters] and add all SP host-headers (like https://*.your-sharepoint.company.com)

 

Written by Alex Anikin

February 13, 2012 at 2:05 pm

Using .Net Framework 4 in PowerShell

leave a comment »

I need use 4 in one of my projects. This because some strong differencies in working with WebRequest. The main thing – in version 3.5 WebRequest don’t want support NTLM authentication scheme.  May be it was my fault, but when i chaged version to 4 my code worked fine.

Project needs – use my code from PowerShell, but it gets me this:

Add-PSSnapin : Cannot load Windows PowerShell snap-in NTLMSnapIn because of the following error: Could not load file or  assembly ‘file:///C:\Users\aanikin\Documents\Visual Studio 2010\Projects\NTLMTest\NTLM.Powershell\bin\Debug\NTLM.Power shell.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

This is not a big problem – solution :

reg add hklm\software\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1

reg add hklm\software\wow6432node\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1

But this was not the end – this experiments was on my SharePoint Server and this registry keys crashed it (CS1703 error about mscorlib, errro 500 in Central Administration). So OnlyUseLatestCLR key will crash SharePoint. Solution:

reg add hklm\software\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 0

reg add hklm\software\wow6432node\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 0

or just delete this key from Registry.

Written by Alex Anikin

January 24, 2012 at 1:36 pm