Arabirim iletişimi için MSMQ kullanan bir uygulama üzerinde çalışıyorum ve henüz yapmadıysa hizmeti yükleyebilmek için kurulum projesine ihtiyacım var. Bunu bir önkoşul haline getirme konusunda kontrol ettim, ancak şu ana kadar bunu bulmakta başarısız oldum. Herhangi bir fikir?Uygulamamın bir önkoşulu olarak MSMQ dahil
cevap
Yanıtı kendi başıma keşfettim ... Windows bileşeni yükleyicisi, herhangi bir anda birden fazla MSI yüklemek için tipik yetersizlik nedeniyle sakat kalmıyor, bu yüzden bir komut yürütmek için özel bir yükleyici eylemi kullanabiliyorum MSMQ yüklemek için çizgi komut dosyası.
İşte (seçeneklerinizi besbelli değişebilir) benim Yükleyici sınıfı var:
public partial class MSMQInstaller : Installer
{
public MSMQInstaller()
{
InitializeComponent();
}
[DllImport("kernel32")]
static extern IntPtr LoadLibrary(string lpFileName);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool FreeLibrary(IntPtr hModule);
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
bool loaded;
try
{
IntPtr handle = LoadLibrary("Mqrt.dll");
if (handle == IntPtr.Zero || handle.ToInt32() == 0)
{
loaded = false;
}
else
{
loaded = true;
FreeLibrary(handle);
}
}
catch
{
loaded = false;
}
if (!loaded)
{
if (Environment.OSVersion.Version.Major < 6) // Windows XP or earlier
{
string fileName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "MSMQAnswer.ans");
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(fileName))
{
writer.WriteLine("[Version]");
writer.WriteLine("Signature = \"$Windows NT$\"");
writer.WriteLine();
writer.WriteLine("[Global]");
writer.WriteLine("FreshMode = Custom");
writer.WriteLine("MaintenanceMode = RemoveAll");
writer.WriteLine("UpgradeMode = UpgradeOnly");
writer.WriteLine();
writer.WriteLine("[Components]");
writer.WriteLine("msmq_Core = ON");
writer.WriteLine("msmq_LocalStorage = ON");
}
using (System.Diagnostics.Process p = new System.Diagnostics.Process())
{
System.Diagnostics.ProcessStartInfo start = new System.Diagnostics.ProcessStartInfo("sysocmgr.exe", "/i:sysoc.inf /u:\"" + fileName + "\"");
p.StartInfo = start;
p.Start();
p.WaitForExit();
}
}
else // Vista or later
{
using (System.Diagnostics.Process p = new System.Diagnostics.Process())
{
System.Diagnostics.ProcessStartInfo start = new System.Diagnostics.ProcessStartInfo("ocsetup.exe", "MSMQ-Container;MSMQ-Server /passive");
p.StartInfo = start;
p.Start();
p.WaitForExit();
}
}
}
}
}
Teşekkür !! İşte ilgilenen herkes için VB.Net sürümü.
Option Explicit On
Option Strict On
Imports System.Diagnostics.Process
Imports System.IO
Imports System.Text
'Required in all cases when calling API functions
Imports System.Runtime.InteropServices
Imports System.Configuration.Install.Installer
<System.ComponentModel.RunInstallerAttribute(True)> _
Public Class msmqInstaller
Inherits System.Configuration.Install.Installer
Private Declare Function LoadLibrary Lib "kernel32" (ByVal lpFileName As String) As IntPtr`enter code here`
<DllImport("KERNEL32.DLL", EntryPoint:="FreeLibrary", SetLastError:=True)> _
Public Shared Function FreeLibrary(ByVal hModule As IntPtr) As Boolean
' Leave function empty - DLLImport attribute
' forces calls to LoadLibrary to
' be forwarded to LoadLibrary in KERNEL32.DLL
End Function
Public Const MAX_PATH As Integer = 256
' Dim testKernel As loadlibrary
Dim p As New Process
' Dim startInfo As New ProcessStartInfo("sysocmgr.exe", "/i:sysoc.inf /u:\"" + fileName + " \ "")
Dim fileName As String = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "MSMQAnswer.ans")
Dim writer As New StreamWriter(fileName)
' Override the 'Install' method of the Installer class. When overridden in a derived class, performs the installation.
'You must override the Install and Uninstall methods to add the code to perform your custom installation steps.
Public Overrides Sub Install(ByVal mySavedState As IDictionary)
MyBase.Install(mySavedState)
Dim loaded As Boolean = False
Dim fileName As String
Dim writer As StreamWriter
Dim p As Process
Try
Dim handle As IntPtr = LoadLibrary("Mqrt.dll")
If handle = IntPtr.Zero Or handle.ToInt32 = 0 Then
loaded = False
Else
loaded = True
FreeLibrary(handle)
End If
Catch ex As Exception
loaded = False
End Try
If Not loaded = True Then
If Environment.OSVersion.Version.Major < 6 Then ' windows xp or earlier
fileName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "MSMQAnswer.ans")
writer = New System.IO.StreamWriter(fileName)
Using writer
writer.WriteLine("[Version]")
' writer.WriteLine("Signature = \"$Windows NT$\"")
writer.WriteLine("Signature = \""$Windows NT$\""")
writer.WriteLine()
writer.WriteLine("[Global]")
writer.WriteLine("FreshMode = Custom")
writer.WriteLine("MaintenanceMode = RemoveAll")
writer.WriteLine("UpgradeMode = UpgradeOnly")
writer.WriteLine()
writer.WriteLine("[Components]")
writer.WriteLine("msmq_Core = ON")
End Using
p = New System.Diagnostics.Process()
Using p
Dim startInfo As New ProcessStartInfo("sysocmgr.exe", "/i:sysoc.inf /u:\" + fileName + " \ ")
p.StartInfo = startInfo
p.Start()
p.WaitForExit()
End Using
Else 'windows vista or later, server 03
p = New System.Diagnostics.Process
Using p
Dim startInfo As New ProcessStartInfo("ocsetup.exe", "MSMQ-Container;MSMQ-Server /passive")
p.StartInfo = startInfo
p.Start()
p.WaitForExit()
End Using
End If
End If
End Sub
End Class
pkgmgr komutu nedir?
Pkgmgr/iu: MSMQ-Container; MSMQ-Server kraker var
Bu, cevabımda "ocsetup.exe" ile aynı şeyi yapıyor gibi görünüyor. –
Ancak Windows 8.1'de varsayılan olarak ocsetup yok – Miguel
- 1. MSMQ
- 2. MSMQ izleme
- 3. Dosya uzantısını, uygulamamın amacına filtre olarak kaydettirin
- 4. MSMQ Azure'da kullanılabilir
- 5. MSMQ Gönderi Mesaj
- 6. mesaj kuyruğu - MSMQ gibi bir şey?
- 7. Windows Hizmetinde MSMQ İletisi İşleme
- 8. MSMQ komut satırı, 7 7
- 9. MSMQ Giden Kuyruğu Nasıl Temizlenir
- 10. MSMQ Tüm Özel Kuyrukları Al
- 11. WCF, MSMQ - 'net.msmq' protokolü desteklenmiyor
- 12. WCF ve MSMQ hatası yönetimi
- 13. MSMQ Uzak Queue'ye ileti gönder
- 14. Android Studio uygulamamın
- 15. Uygulamamın arka planını ayarla
- 16. Uygulamamın indirme sayısı
- 17. ActiveRecord to_json: koşullu olarak ilişkilendirmeleri dahil et
- 18. PHP'de MSMQ iletileri için kurtarılabilir özniteliği ayarlama
- 19. Javascript - Object int olarak dahil JSON ayrıştırma
- 20. MSMQ Uzak özel sıraları okuma sorunu (tekrar)
- 21. Appfog uygulamamın canlı dosya sistemini nasıl indirebilirim?
- 22. Windows Hizmeti olarak MSMQ için bir C# Dinleyici Hizmeti Nasıl Oluşturulur
- 23. WCF 4.0 Zehirli İleti Gönderme MSMQ 4.0
- 24. Otomatik dahil javascript dosyası dahil değilse
- 25. MSMQ, TCP veya UDP üzerinde çalışıyor mu?
- 26. Twig embed vs dahil, kullanmak için herhangi bir neden dahil
- 27. UITapGestureRecognizer'ı uygulamamın içine nasıl uygularım
- 28. Uygulamamın Uygulama İzni ekranına git
- 29. Uygulamamın veri trafiğini nasıl ölçerim?
- 30. Ayrı bir dosyadan bir Ruby sınıfı dahil
. Paylaşım için teşekkürler. –
Yükleme yöntemini nasıl çağırırsınız? Ben zaten sistem.configuration.Install 'Referansı ekledim InitializeComponent yöntemi üssünde bir yöntem mi? msmq yüklemek için bu sınıfı nasıl kullanabilirim? –
@Adam: Bu yükleyici sınıfı için ayrı bir sınıf kitaplığı aldınız mı? Kodunuzu kullandığımda "InitializeComponent bulunamıyor" hatası alıyorum. – Abhishek