How to bring to front the custom form in setup project No Comments

  1.  public class MsiWindow : IWin32Window
  2.     {
  3.         private IntPtr _hwnd;
  4.         static MsiWindow  _window;
  5.         static object obj = new object();
  7.         public MsiWindow(IntPtr handle)
  8.         {
  9.             _hwnd = handle;
  10.         }
  12.         public IntPtr Handle
  13.         {
  14.             get { return _hwnd; }
  15.         }
  17.         private static IntPtr GetMsiHandle()
  18.         {
  19.             IntPtr hwnd = IntPtr.Zero;
  21.             foreach (var proc in Process.GetProcessesByName("msiexec"))
  22.             {
  23.                 if (proc.MainWindowHandle == IntPtr.Zero)
  24.                     continue;
  26.                 if (string.IsNullOrEmpty(proc.MainWindowTitle))
  27.                     continue;
  29.                 hwnd = proc.MainWindowHandle;
  30.                 break;
  32.             }
  34.             return hwnd;
  35.         }
  37.         public static MsiWindow GetMsiWindow()
  38.         {
  39.             if (_window == null)
  40.             {
  41.                 lock (obj)
  42.                 {
  43.                     if (_window == null)
  44.                     {
  45.                         _window = new MsiWindow(GetMsiHandle());
  46.                     }
  47.                 }
  48.             }
  49.             return _window;
  50.         }
  52.     }

to use this class

  1. frmConfig config = new frmConfig();
  2. frmConfig.ShowDialog(MsiWindow.GetMsiWindow());

Issue: FileUpload inside MultiView not working on First Postback in ASP.Net No Comments

I had this problem in one of my project job, it took me sometime to figure out who was the culprit.
However, when I look at the source view of the loaded page on the browser, the “form” element has no enctype=”multipart/form-data” attribute which is required in uploading a file. While the FileUpload element was in the 3rd view, I need to put a fake or dummy FileUpload that will always visible (style=”display:none”) to engine.

Asp.Net Mvc no intellisense in views No Comments

I have experienced this problem after installing visual studio 2013 web express, doing google answers resolved this problem.
To resolve this problem, find the web.config under “Views” folder and add the highlighted element below.

  1.  <appSettings>
  2.      <add key="webpages:Version" value=""/>
  3.  </appSettings>

Sql Server Installation Wizard Disappear No Comments

I have this problem when I tried reinstalling SQL SERVER 2008 R2 and SQL SERVER 2012. Just following this thread from Microsoft, it solved this problem.

Here’s how I did it
1. Find the SqlSetup.log in temp folder by typing %temp%.
2. If the you see this type of error “Error: Cannot load .Net security policy file” then, your good (just execute step 3)
3. Bring up the command promp (runAs admin) and type this – “C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CasPol.exe -machine -reset”.

Error:Configuration system failed to initialize exception in No Comments

I had this problem when I have converted my VB.Net Project Framework from 3.5 to 4.
My solution is to delete the app.config, after that I open the project properties, goto Settings Tab and just alter / add a dummy text and save it, Visual Studio will generate a new app.config.

Error: Mixed mode in assembly in .NET 4 No Comments

This error usually appears after converting a project from .net any lower verson to .net 4 and this project also had referenced another .net project with lower version.
To solve this error simply add the below configuration into your project app.config or web.config inside element.

  1. <startup useLegacyV2RuntimeActivationPolicy="true">
  2.     <supportedRuntime version="v4.0"/>
  3. </startup>

Issue: SelectedItem of the Listview is delayed No Comments

I have developed an website and I used the Listview control for some of the website navigation and define its style.
Now, the problem was when you clicked the link on the first time, the selected item would not be highlighted as what I have defined the style when selected, and on the second.. third.. time of selection, the previous selected link would be the one highlighted and not the current one. As usual GOOGLE is the world wide web friend, I ran into a blog that encountered the same problem as mine.
Here’s what I have done to solve the problem.

On the SelectedIndexChanging event of the Listview, I set the SelectedIndex and reload the data of the listview and now its working.

  1. protected void lvwSequence_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
  2. {
  3.             lvwSequence.SelectedIndex = e.NewSelectedIndex;
  4.             this._processPresenter.LoadWFSequence();
  5. }

Issue:Listview inside UpdatePanel not working No Comments

I had this web project using ASP.Net, its all good until I had to use a ListView control to create a list clickable items. And, because I want it to be more responsive so I wrapped it with UpdatePanel, however, when you click a link inside it, it would do a full Postback instead of partial Postback. I also took me sometime to figured it out. One solution that I used was I added an ClientIDMode=”AutoID” on the page directive.

How to concatenate rows in sql server using XML No Comments

  2.       fileid
  3.     , STUFF((
  4.         SELECT N', ' + CAST([filename] AS VARCHAR(255))
  5.         FROM tblFile f2
  6.         WHERE f1.fileid = f2.fileid —- string with grouping by fileid
  7.         FOR XML PATH ('')), 1, 2, '') AS FileNameString
  8. FROM tblFile f1

Error: Unable to find assembly Serialization Exception No Comments

I’ve got this issue when we’re developing an Microsoft office Addin integration project, however, the assembly causing this error has been tested and deployed with our different products and projects and we have not encountered this type of error until we have use this one of our Microsoft office Addin project.
Luckily, after googling we have fixed it by refering this blog.
And, here’s the code I use.

  1. AppDomain.CurrentDomain.AssemblyResolve +=
  2.         new ResolveEventHandler(CurrentDomain_AssemblyResolve);
  4.     // deserialization code here
  6.     // *** Unhook the event handler for the rest of the application
  7.     AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(CurrentDomain_AssemblyResolve);

  1. /// <summary>
  2. /// Handle custom loading of the current assembly if the assmebly won't
  3. /// resolve with the name.
  4. /// </summary>
  5. /// <param name="sender"></param>
  6. /// <param name="args"></param>
  7. /// <returns></returns>
  10. static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
  11. {
  12.     try
  13.     {
  14.         Assembly assembly = System.Reflection.Assembly.Load(args.Name);
  15.         if (assembly != null)
  16.             return assembly;
  17.     }
  18.     catch { ;}
  20.     return Assembly.GetExecutingAssembly();            
  21. }