Showing posts with label .Net. Show all posts
Showing posts with label .Net. Show all posts

10/25/2017

nopCommerce 3.90 - Related Problem



Add Entity Migrations


Reference Data :
https://www.pronopcommerce.com/using-entity-framework-ef-code-first-migrations-in-nopcommerce-for-fast-customizations

Steps:
  1. Install nopCommerce
  2. Enabled-Migrations.  If you get error messages when you try to enable migration, update all Entity Frameworks to varsion 6.1.2.  Then, enable the migration again.
  3. add-migration InitialMigration -IgnoreChanges

Build nopCommerce in Release configuration, some packages are not valid.


Reference Data :
https://www.nopcommerce.com/boards/t/32421/solution-build-error-rebuild-solution-failed-in-release-mode-340.aspx

Change Slide Picture

Reference Data:
https://www.nopcommerce.com/boards/t/38721/changing-the-slideshow-images-on-the-homepage.aspx

Log4Net

https://sadi02.wordpress.com/2008/09/15/how-to-store-log-in-database-using-log4net/

How to subscribe to an event in a plugin?

https://www.nopcommerce.com/boards/t/12719/how-to-subscribe-to-an-event-in-a-plugin.aspx

Creating a custom task. V3.0 or later

https://www.nopcommerce.com/boards/t/28253/creating-a-custom-task-v30-or-later.aspx

10/23/2017

Integrate .Net Object into Talend


Related link: http://talendforge.org/wiki/doku.php?id=doc:dotnet

1. Remember to download janet-win and follow the instruction to install the dll.
2. Talend .Net component can only load DLL, cannot load EXE.

1/09/2017

.Net Send Email Problem - net_io_connectionclosed

最近在 migrate 舊的 .net 程式到 Windows Server 上, 其中有一個 SMTP 的 Setting 造成 Email Send 不出去, 得到下列的 Error Message.

System.Net.Mail.SmtpException: net_io_connectionclosed

Program 是 .Net 2.0, Server 是 Windows

Server 2008 在這篇文章中找到 Solution.

I ran into this today and the solution is tied somehow to the IP addresses you are using to secure the SMTP virtual server.  My server has multiple IP addresses bound to the same adapter and the VS was configured to use one of them.  However, I had all of the access restrictions to allow connections only from 127.0.0.1 which is the source of the error (I believe.

So, whatever the IP address your VS is listening on OR the IP your application is configured to use, configure the following areas:
  • Access/Connection control/Only the list below/[add your server ip]
  • Access/Relay restrictions/Only the list below/[add your server ip]
  • Configure your application to utilized the server ip, not localhost or 127.0.0.1

2/14/2014

IE animation GIF freezed.

Original Link: http://weblog.west-wind.com/posts/2004/Dec/27/Animated-GIF-images-in-hidden-page-elements

我們常會在 Process 時, popup 一個會動的 icon, 表示在進行中. 這的動作常用 animation gif 來達成.

在 IE 7 以後,常常只顯示出圖片, 但是不會動.  這是 IE 已知的 Bug, 很久都沒有 Fix. 底下這段 Code 是從 Internet 上找到的, 可以 Work.

function ShowWaitDisplay()
{
   document.getElementById('MainForm').style.display='none';
   document.getElementById('WaitNote').style.display='inline';
   Img = document.getElementById('WaitImage');
   Img.style.display="inline";
   Img.src = "images/pleasewait.gif";
   window.scrollTo(0,0);
   return true;     
}

3/08/2013

How to get IPV4 from IPV6 Environment?

Reference Link: http://www.4guysfromrolla.com/articles/071807-1.aspx  

using System;
using System.Net;

public class IPNetworking
{
  public static string GetIP4Address()
  {
    string IP4Address = String.Empty;

    foreach (IPAddress IPA in Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress))
    {
      if (IPA.AddressFamily.ToString() == "InterNetwork")
      {
        IP4Address = IPA.ToString();
        break;
      }
    }

    if (IP4Address != String.Empty)
    {
      return IP4Address;
    }

    foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
    {
      if (IPA.AddressFamily.ToString() == "InterNetwork")
      {
        IP4Address = IPA.ToString();
        break;
      }
    }

    return IP4Address;
  }
}

8/20/2012

Hostgator Session Timeout 太快的問題

最近在 Hostgator 上碰到個問題, User Login 進去後, 很快就 Session timeout, 被踢出來, 不明其原因. 又加上是 Shared Web Hosting, 根本沒有辦法去改到 IIS 的設定.

有一說是因為 Application Pool 不定時回收, Default 設定是五分鐘, 當 Application Pool 回收時, 會自動把所有的 Session Reset, 所以就 Timeout 掉了.

問題來了, 我又不能去改 IIS 設定, 那該如何處理? 

後來找到一篇文章, 上面提到的方式, 可以解決我的問題 ==> 就是它

他的 Solution 就是去 Web.config 裡面加上一組 machinekey, 就解決了.

這裡有個 machinekey generator, 用它產生 Machine Key 然後貼到 Web.config 中的 <System.web> Section 中, 在 Hostgator 被 Timeout 掉的問題就解決了!


8/15/2012

C# : How to Identify a Nullable Type

在 .Net Coding 中, 我常會用 class destructor 把一些 Resource Release 掉.

因為 .Net 本身有 Garbage Collection 的功能, 所以只要把已經 Allocate Resources 的 Object 指定為 Null 或是 Empty, 原來 Allocate 的 Resources 就變成無主孤兒,  將會被 Garbage Collection 回收.

問題來了, 不是每個 Type 都是 Nullable, 要如何判斷 Nullable, MS 在 MSDN 中提供了方法, 裡面還有些 Trick.

請參考: http://msdn.microsoft.com/en-us/library/ms366789.aspx

Use the following code to determine whether a Type object represents a Nullable type. Remember that this code always returns false if the Type object was returned from a call to GetType, as explained earlier in this topic.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) {…}