Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4a05993

Browse files
committed
fix add file reference (com dll)
lcid is an integerfix typelib registry path, the lcid part is the hexadecimal string representation of the lcid valueadded exception on failed add referencefix nre on if registry key not foundfixdotnet#278
1 parent9c53f72 commit4a05993

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

‎vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/VSProject/OAComReference.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override string Culture
2727
intlocale=0;
2828
try
2929
{
30-
locale=int.Parse(BaseReferenceNode.LCID,CultureInfo.InvariantCulture);
30+
locale=BaseReferenceNode.LCID;
3131
}
3232
catch(System.FormatException)
3333
{

‎vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ComReferenceNode.cs‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ [ DllImport( "oleaut32.dll", CharSet = CharSet.Unicode, PreserveSig = false )]
4242
privatestringinstalledFilePath;
4343
privatestringminorVersionNumber;
4444
privatestringmajorVersionNumber;
45-
privatestringlcid;
45+
privatereadonlyintlcid;
4646
#endregion
4747

4848
#region properties
@@ -76,7 +76,7 @@ public string InstalledFilePath
7676
}
7777

7878
[SuppressMessage("Microsoft.Naming","CA1709:IdentifiersShouldBeCasedCorrectly",MessageId="LCID")]
79-
publicstringLCID
79+
publicintLCID
8080
{
8181
get{returnlcid;}
8282
}
@@ -133,7 +133,7 @@ internal ComReferenceNode(ProjectNode root, ProjectElement element)
133133

134134
this.majorVersionNumber=this.ItemNode.GetMetadata(ProjectFileConstants.VersionMajor);
135135
this.minorVersionNumber=this.ItemNode.GetMetadata(ProjectFileConstants.VersionMinor);
136-
this.lcid=this.ItemNode.GetMetadata(ProjectFileConstants.Lcid);
136+
this.lcid=int.Parse(this.ItemNode.GetMetadata(ProjectFileConstants.Lcid));
137137
this.SetProjectItemsThatRelyOnReferencesToBeResolved(false);
138138
this.SetInstalledFilePath();
139139
}
@@ -161,14 +161,15 @@ internal ComReferenceNode(ProjectNode root, VSCOMPONENTSELECTORDATA selectorData
161161
this.typeGuid=selectorData.guidTypeLibrary;
162162
this.majorVersionNumber=selectorData.wTypeLibraryMajorVersion.ToString(CultureInfo.InvariantCulture);
163163
this.minorVersionNumber=selectorData.wTypeLibraryMinorVersion.ToString(CultureInfo.InvariantCulture);
164-
this.lcid=selectorData.lcidTypeLibrary.ToString(CultureInfo.InvariantCulture);
164+
this.lcid=(int)selectorData.lcidTypeLibrary;
165165

166166
// Check to see if the COM object actually exists.
167167
this.SetInstalledFilePath();
168168
// If the value cannot be set throw.
169169
if(String.IsNullOrEmpty(this.installedFilePath))
170170
{
171-
thrownewArgumentException();
171+
varmessage=string.Format(SR.GetString(SR.ReferenceCouldNotBeAdded,CultureInfo.CurrentUICulture),selectorData.bstrTitle);
172+
thrownewInvalidOperationException(message);
172173
}
173174
}
174175

@@ -195,14 +196,15 @@ internal ComReferenceNode(ProjectNode root, string filePath)
195196
this.typeGuid=typeAttr.guid;
196197
this.majorVersionNumber=typeAttr.wMajorVerNum.ToString(CultureInfo.InvariantCulture);
197198
this.minorVersionNumber=typeAttr.wMinorVerNum.ToString(CultureInfo.InvariantCulture);
198-
this.lcid=typeAttr.lcid.ToString(CultureInfo.InvariantCulture);
199+
this.lcid=typeAttr.lcid;
199200

200201
// Check to see if the COM object actually exists.
201202
this.SetInstalledFilePath();
202203
// If the value cannot be set throw.
203204
if(String.IsNullOrEmpty(this.installedFilePath))
204205
{
205-
thrownewArgumentException();
206+
varmessage=string.Format(SR.GetString(SR.ReferenceCouldNotBeAdded,CultureInfo.CurrentUICulture),filePath);
207+
thrownewInvalidOperationException(message);
206208
}
207209
}
208210
finally
@@ -281,21 +283,20 @@ internal ComReferenceNode(ProjectNode root, string filePath)
281283
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization","CA1308:NormalizeStringsToUppercase")]
282284
privateProjectElementGetProjectElementBasedOnInputFromComponentSelectorData()
283285
{
284-
285286
ProjectElementelement=newProjectElement(this.ProjectMgr,this.typeName,ProjectFileConstants.COMReference);
286287

287288
// Set the basic information regarding this COM component
288289
element.SetMetadata(ProjectFileConstants.Guid,this.typeGuid.ToString("B"));
289290
element.SetMetadata(ProjectFileConstants.VersionMajor,this.majorVersionNumber);
290291
element.SetMetadata(ProjectFileConstants.VersionMinor,this.minorVersionNumber);
291-
element.SetMetadata(ProjectFileConstants.Lcid,this.lcid);
292+
element.SetMetadata(ProjectFileConstants.Lcid,this.lcid.ToString());
292293
element.SetMetadata(ProjectFileConstants.Isolated,false.ToString());
293294

294295
// See if a PIA exist for this component
295296
TypeLibConvertertypelib=newTypeLibConverter();
296297
stringassemblyName;
297298
stringassemblyCodeBase;
298-
if(typelib.GetPrimaryInteropAssembly(this.typeGuid,Int32.Parse(this.majorVersionNumber,CultureInfo.InvariantCulture),Int32.Parse(this.minorVersionNumber,CultureInfo.InvariantCulture),Int32.Parse(this.lcid,CultureInfo.InvariantCulture),outassemblyName,outassemblyCodeBase))
299+
if(typelib.GetPrimaryInteropAssembly(this.typeGuid,Int32.Parse(this.majorVersionNumber,CultureInfo.InvariantCulture),Int32.Parse(this.minorVersionNumber,CultureInfo.InvariantCulture),this.lcid,outassemblyName,outassemblyCodeBase))
299300
{
300301
element.SetMetadata(ProjectFileConstants.WrapperTool,WrapperToolAttributeValue.Primary.ToString().ToLowerInvariant());
301302
}
@@ -325,7 +326,7 @@ private void SetProjectItemsThatRelyOnReferencesToBeResolved(bool renameItemNode
325326
if(String.Compare(MSBuildItem.GetMetadataValue(reference,ProjectFileConstants.Guid),this.typeGuid.ToString("B"),StringComparison.OrdinalIgnoreCase)==0
326327
&&String.Compare(MSBuildItem.GetMetadataValue(reference,ProjectFileConstants.VersionMajor),this.majorVersionNumber,StringComparison.OrdinalIgnoreCase)==0
327328
&&String.Compare(MSBuildItem.GetMetadataValue(reference,ProjectFileConstants.VersionMinor),this.minorVersionNumber,StringComparison.OrdinalIgnoreCase)==0
328-
&&String.Compare(MSBuildItem.GetMetadataValue(reference,ProjectFileConstants.Lcid),this.lcid,StringComparison.OrdinalIgnoreCase)==0)
329+
&&String.Compare(MSBuildItem.GetMetadataValue(reference,ProjectFileConstants.Lcid),this.lcid.ToString(),StringComparison.OrdinalIgnoreCase)==0)
329330
{
330331
stringname=MSBuildItem.GetEvaluatedInclude(reference);
331332
if(Path.IsPathRooted(name))
@@ -365,9 +366,16 @@ private void SetInstalledFilePath()
365366
this.typeName=typeLib.GetValue(string.Empty)asstring;
366367
}
367368
// Now get the path to the file that contains this type library.
368-
using(RegistryKeyinstallKey=typeLib.OpenSubKey(string.Format(CultureInfo.InvariantCulture,@"{0}\win32",this.lcid)))
369+
370+
// lcid
371+
// The hexadecimal string representation of the locale identifier (LCID).
372+
// It is one to four hexadecimal digits with no 0x prefix and no leading zeros.
373+
using(RegistryKeyinstallKey=typeLib.OpenSubKey(string.Format(CultureInfo.InvariantCulture,@"{0:X}\win32",this.lcid)))
369374
{
370-
this.installedFilePath=installKey.GetValue(String.Empty)asString;
375+
if(installKey!=null)
376+
{
377+
this.installedFilePath=installKey.GetValue(String.Empty)asString;
378+
}
371379
}
372380
}
373381
}

‎vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Microsoft.VisualStudio.Package.Project.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ protected override string GetLocalizedString(string value)
153153
/*internal, but public for FSharp.Project.dll*/publicconststringProjectProperties="ProjectProperties";
154154
/*internal, but public for FSharp.Project.dll*/publicconststringQuiet="Quiet";
155155
/*internal, but public for FSharp.Project.dll*/publicconststringQueryReloadNestedProject="QueryReloadNestedProject";
156+
/*internal, but public for FSharp.Project.dll*/publicconststringReferenceCouldNotBeAdded="ReferenceCouldNotBeAdded";
156157
/*internal, but public for FSharp.Project.dll*/publicconststringReferenceAlreadyExists="ReferenceAlreadyExists";
157158
/*internal, but public for FSharp.Project.dll*/publicconststringReferenceWithAssemblyNameAlreadyExists="ReferenceWithAssemblyNameAlreadyExists";
158159
/*internal, but public for FSharp.Project.dll*/publicconststringReferencesNodeName="ReferencesNodeName";

‎vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Microsoft.VisualStudio.Package.Project.resx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@
125125
<value>Advanced</value>
126126
<comment>Project Property Page Caption</comment>
127127
</data>
128+
<dataname="ReferenceCouldNotBeAdded"xml:space="preserve">
129+
<value>A reference to '{0}' could not be added.</value>
130+
<comment>ReferenceCouldNotBeAdded error message</comment>
131+
</data>
128132
<dataname="ReferenceAlreadyExists"xml:space="preserve">
129133
<value>A reference to '{0}' could not be added. A reference to the component '{1}' already exists in the project.</value>
130134
<comment>ReferenceAlreadyExists error message</comment>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp