ServerDocument.AddCustomization Yöntem (String, Uri)
Bir özelleştirme, belirtilen derleme adı ve dağıtım bildirimi kullanarak belirtilen belgeye ekler.
Ad alanı: Microsoft.VisualStudio.Tools.Applications
Derleme: Microsoft.VisualStudio.Tools.Applications.ServerDocument (Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll içinde)
Sözdizimi
'Bildirim
Public Shared Sub AddCustomization ( _
documentPath As String, _
deploymentManifestUrl As Uri _
)
public static void AddCustomization(
string documentPath,
Uri deploymentManifestUrl
)
Parametreler
- documentPath
Tür: System.String
Bir özelleştirme eklemek istediğiniz belgenin tam yolu.
- deploymentManifestUrl
Tür: System.Uri
Çözüm dağıtım listesi URL'si.
Özel Durumlar
Exception | Koşul |
---|---|
ArgumentNullException | documentPathor deploymentManifestUrl is nullnull başvuru (Visual Basic\'te Nothing) or empty. |
ArgumentException | deploymentManifestUrlmutlak bir url belirtmiyor. |
FileNotFoundException | documentPathveya deploymentManifestUrl var olmayan bir dosyaya başvuruyor. |
DocumentAlreadyCustomizedException | Belirtilen belge documentPath zaten özelleştirme. |
InvalidManifestException | Dağıtım listesi tarafından belirtilen deploymentManifestUrl olmayan bir geçerli dağıtım listesi. |
DocumentNotCustomizedException | Belirtilen belge documentPath bozuk, veya kısıtlı izinleri. |
UnknownCustomizationFileException | Belirtilen belge documentPath tarafından desteklenmeyen bir dosya adı uzantısına sahip Visual Studio Tools for Office çalışma zamanı modülü. |
Açıklamalar
AddCustomization Yöntemi associates belirtilen özelleştirme belgeyle ekleyerek _AssemblyName ve _AssemblyLocation özel belge özellikleri belge. Bu özellikler belge bir özelleştirme sahiptir ve dağıtım bildirim konumunu tanımlar. Bu yöntem başarılı bir şekilde, bir kullanıcı belirtilen belge bir sonraki açışında çağrıldıktan sonra çalışma zamanı Office çözümü yüklemeye çalışır. Özel belge özellikleri hakkında daha fazla bilgi için bkz: Özel Belge Özelliklerine Genel Bakış.
Belirtilen belge özelleştirme beklediği için belge denetim içermiyorsa, AddCustomization yöntemi başarılı olur, ancak derleme açtığında yüklemek başarısız olurbelge.
fileType Parametresi için desteklenen dosya adı uzantısına sahip bir belge belirtmeniz gerekirbelge düzeyinde özelleştirmeleri. Word xml belgesinde kayıtlı olan bir belgeye bir özelleştirme eklenemiyor (* xml) veya Word 2003 xml belgesi (* xml) dosya formatları. Desteklenen dosya türleri hakkında daha fazla bilgi için bkz: Belge Düzeyi Özelleştirmeleri Mimarisi.
Örnekler
Aşağıdaki kod örneği AddCustomization yöntemine ekleyin bir özelleştirme için belirtilen belge.
Bu örnek aşağıdakileri gerektirir:
Bir konsol uygulaması projesi veya başka bir Office dışı projeye.
Aşağıdaki derlemelerine başvurular:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.dll (eğer proje .NET Framework 4'i hedefliyorsa).
ya da
Microsoft.Visualstudio.Tools.Applications.ServerDocument.V10.0.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (, proje hedefleri.net Framework 3.5).
Imports(Visual Basic için) veya using (için C#) ifadeleri için Microsoft.VisualStudio.Tools.Applications ve Microsoft.VisualStudio.Tools.Applications.Runtime ad alanları üst kod dosyası.
Private Sub AddCustomizationUsingDocumentPath(ByVal documentPath As String, _
ByVal deployManifestPath As String)
Dim runtimeVersion As Integer = 0
Try
' Make sure that this document does not yet have any Visual Studio Tools
' for Office customizations.
runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
If runtimeVersion = 0 Then
Dim deploymentManifestUri As New Uri(deployManifestPath)
ServerDocument.AddCustomization(documentPath, deploymentManifestUri)
MessageBox.Show("The document was successfully customized.")
Else
System.Windows.Forms.MessageBox.Show("The document is already customized.")
End If
Catch ex As System.IO.FileNotFoundException
System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
Catch ex As UnknownCustomizationFileException
System.Windows.Forms.MessageBox.Show("The specified document has a file " & _
"extension that is not supported by Visual Studio Tools for Office.")
Catch ex As DocumentNotCustomizedException
System.Windows.Forms.MessageBox.Show("The document could not be customized." & _
vbLf & ex.Message)
End Try
End Sub
private void AddCustomizationUsingDocumentPath(string documentPath, string deployManifestPath)
{
int runtimeVersion = 0;
try
{
runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);
// Make sure that this document does not yet have any Visual Studio Tools
// for Office customizations.
if (runtimeVersion == 0)
{
Uri deploymentManifestUri = new Uri(deployManifestPath);
ServerDocument.AddCustomization(documentPath, deploymentManifestUri);
MessageBox.Show("The document was successfully customized.");
}
else
{
System.Windows.Forms.MessageBox.Show("The document is already customized.");
}
}
catch (System.IO.FileNotFoundException)
{
System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
}
catch (UnknownCustomizationFileException)
{
System.Windows.Forms.MessageBox.Show("The specified document has a file " +
"extension that is not supported by Visual Studio Tools for Office.");
}
catch (DocumentNotCustomizedException ex)
{
System.Windows.Forms.MessageBox.Show("The document could not be customized.\n" +
ex.Message);
}
}
.NET Framework Güvenliği
- Anında arayanlar için tam güven. Bu üye kısmen güvenilen kodla kullanılamaz. Daha fazla bilgi için bkz. kısmen güvenilir kod tarafından Kitaplıklar kullanma.